HTL AEM 6.3 DateFormat | Community
Skip to main content
mikezooz
March 7, 2018
Solved

HTL AEM 6.3 DateFormat

  • March 7, 2018
  • 8 replies
  • 10204 views

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.
Best answer by zeeshanKhan0786

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

smacdonald2008
March 7, 2018

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

mikezooz
mikezoozAuthor
March 7, 2018

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.

smacdonald2008
March 7, 2018

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

smacdonald2008
March 7, 2018

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.

Ratna_Kumar
March 7, 2018

Yes, Scott is right.

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

mikezooz
mikezoozAuthor
March 7, 2018

Could you please provide the code snippet.

smacdonald2008
March 7, 2018

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

zeeshanKhan0786
zeeshanKhan0786Accepted solution
May 13, 2019

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.