Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.
SOLVED

HTL AEM 6.3 DateFormat

Avatar

Level 4

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?

1 Accepted Solution

Avatar

Correct answer by
Level 5

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.

View solution in original post

8 Replies

Avatar

Level 10

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

Avatar

Level 4

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.

Avatar

Level 10

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.

Avatar

Level 10

Yes, Scott is right.

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

Avatar

Level 4

Could you please provide the code snippet.

Avatar

Level 10

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

Avatar

Correct answer by
Level 5

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.