Expand my Community achievements bar.

SOLVED

Date/Time Problem with javascript scripting

Avatar

Level 3

Hello All,

I need to maintain some history on my pdf form, so i need to get date and time when user submits the form.  Right now i'm able to do this in FormCalc.

var todayDate = Date()
var todayTime = Time()
var today = concat(Num2Date(todayDate, "MMMM DD, YYYY"), " ", Num2Time(todayTime, "h:MM A"));

today will contain:  April 28, 2009 2:23 PM

I want exact functionality in javascript.  I'm not able to get the same result.

Please give me some code snippet for the same in javascript

Deepak.

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

Hi Deepak,

This sample should show you how you can retrieve each "piece" of the date in JavaScript and then piece them back together as you need.

You can find more script examples on date formatting here: http://javascript.internet.com/time-date/

View solution in original post

2 Replies

Avatar

Correct answer by
Former Community Member

Hi Deepak,

This sample should show you how you can retrieve each "piece" of the date in JavaScript and then piece them back together as you need.

You can find more script examples on date formatting here: http://javascript.internet.com/time-date/

Avatar

Level 3

Hi leesutton...

Thank you very much for your reply.

I have got another solution from the net while surfing.  Here is it:

var today = util.printd("mmmm dd, yyyy h:MM tt", new Date());

form.page1.textfield.rawValue = today;

Any ways thanks a lot for helping...

Deepak

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----