HTL AEM 6.3 DateFormat | Community
Skip to main content
mikezooz
Level 4
Mar 7, 2018 3:42 PM UTC
Solved

HTL AEM 6.3 DateFormat

AEM 6.3 Date format, i have created the below HTL

<h2>${ 'MM/dd/yyyy HH:mma' @ format=pageProperties.cq:lastReplicated}</h2>

its provide the output as "<h2>03/07/2018 20:08PM</h2>"

I have requirement to change the PM as pm, likewise AM as am (Lowercase). Is that acheivable using HTL?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
zeeshanKhan0786
zeeshanKhan0786Accepted solution
Level 5
May 13, 2019 7:29 AM UTC

HI michaelvino86​

You can use

  1. <h2>${ 'dd-MM-yyyy' @ format=currentPage.jcr:created}</h2>

  1. <h2>${ 'dd-MMM-yyyy hh:mm:ss' @ format=currentPage.jcr:created, timezone='PST'}</h2>

  1. <h2>${ 'dd-MMMM-yyyy hh:mm:ss' @ format=currentPage.jcr:created, timezone='PST', locale='fr'}</h2>

To directly formet the date after AEM6.2.

8 replies

zeeshanKhan0786
zeeshanKhan0786Accepted solution
Level 5
May 13, 2019 7:29 AM UTC

HI michaelvino86​

You can use

  1. <h2>${ 'dd-MM-yyyy' @ format=currentPage.jcr:created}</h2>

  1. <h2>${ 'dd-MMM-yyyy hh:mm:ss' @ format=currentPage.jcr:created, timezone='PST'}</h2>

  1. <h2>${ 'dd-MMMM-yyyy hh:mm:ss' @ format=currentPage.jcr:created, timezone='PST', locale='fr'}</h2>

To directly formet the date after AEM6.2.

Translate
smacdonald2008
Level 10
Mar 7, 2018 7:50 PM UTC

See the links provided in this thread to see how to use JS to lower case a string.

Translate
mikezooz
mikezoozAuthor
Level 4
Mar 7, 2018 5:22 PM UTC

Could you please provide the code snippet.

Translate
Ratna_Kumar
Level 10
Mar 7, 2018 5:03 PM UTC

Yes, Scott is right.

You can simply parse using Java Script as given in link: JavaScript String toLowerCase() Method

Translate
smacdonald2008
Level 10
Mar 7, 2018 4:02 PM UTC

To learn how to use JS API for HTL -- see this HELPX Article -- Creating a Tab layout component for Adobe Experience Manager

The use case here is a tab-based HTL component - but it shows use of the JS API for HTL. We have articles too for WCMUSePojo and Sling Models.

Translate
smacdonald2008
Level 10
Mar 7, 2018 4:00 PM UTC

This is standard JS functionality -- JavaScript String toLowerCase() Method

Translate
mikezooz
mikezoozAuthor
Level 4
Mar 7, 2018 3:57 PM UTC

Do you want me to use java or javascript to parse the string? i was thinking like, for a small change is that required to create a use-API.

I am looking for a solution from HTL itself. Correct me if i am wrong.

Translate
smacdonald2008
Level 10
Mar 7, 2018 3:49 PM UTC

You can parse the string and change the case using custom logic.

Translate