Expand my Community achievements bar.

SOLVED

Current time and date with AM/PM - not military time.

Avatar

Level 9

I need to display the current date and time in a textfield that is dynamicaly created. I do not want that time or date to change (remains the same as long as that field stays displayed and the form is saved.) I need it in the following format: Monday, 4/02/2012, 3:03 PM

I have the following javascript that works but lacks the format and some info needed listed above: (AM/PM day of the week)

this.rawValue = util.printd("mm/dd/yy - h:MM ", new Date() );

 

1 Accepted Solution

Avatar

Correct answer by
Level 10

That should work but it's FormCalc date notation not JavaScript.

Though I was just playing around with it and it looks like time and date are separate in FormCalc - unless someone knows different?

I tried the following and it worked:

$ = Concat(num2date(date(), "EEEE, MM/DD/YYYY"), Space(1), num2time(time(), "h:MM A"))


Message was edited: Removed some extra brackets that weren't needed in the script.

View solution in original post

9 Replies

Avatar

Level 7

The pattern you want to use is: EEEE, MM/DD/YYYY, h:MM A

Avatar

Level 9

I was not able to reply yesterday - that option was not displayed.

Unfortunitly, EEEE, MM/DD/YYYY, h:MM A does not work in the textfield, and I need to have it in a textfield.

Thanks for your reply.

~Don

Avatar

Correct answer by
Level 10

That should work but it's FormCalc date notation not JavaScript.

Though I was just playing around with it and it looks like time and date are separate in FormCalc - unless someone knows different?

I tried the following and it worked:

$ = Concat(num2date(date(), "EEEE, MM/DD/YYYY"), Space(1), num2time(time(), "h:MM A"))


Message was edited: Removed some extra brackets that weren't needed in the script.

Avatar

Level 9

Did not realize it was FormCalc - works great!

Thank you, thank you!

~Don

Avatar

Level 9

Is there a way in FormCalc to shorten the day to three digets (Shorten Wednesday to "Wed")>

thanks again!

don

Avatar

Level 9

Thank you - I'm new to FormCalc.

~Don

Avatar

Level 10

I don't use FormCalc a lot but it's really good for dates and calculating using repeating objects.

FormCalc reference:

http://help.adobe.com/en_US/livecycle/9.0/FormCalc.pdf

Picture Clause reference:

http://partners.adobe.com/public/developer/en/xml/picture_clause_2.0.pdf

Avatar

Level 9

Thanks for the links and the help!

~Don