Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

JavaScript time

Avatar

Level 9

I need to use JavaScript and want the current time to display with either AM or PM.

I have the following script:

util.printd("m/d/yyyy h:MM A, new Date),

but it does not display AM or PM.

Is there a way to script this using javaScript?

1 Accepted Solution

Avatar

Correct answer by
Level 6

Is that really the exact script you're using? If so, try this:

util.printd("m/d/yyyy h:MM tt", new Date())

This will give am or pm, so you'll have to capitalize the resulting string if you want AM/PM.

View solution in original post

2 Replies

Avatar

Correct answer by
Level 6

Is that really the exact script you're using? If so, try this:

util.printd("m/d/yyyy h:MM tt", new Date())

This will give am or pm, so you'll have to capitalize the resulting string if you want AM/PM.

Avatar

Level 9

That's exactly what I was missing! Thank you so much!

-Don