Current Date & Time using HTL
Hello - Is there a way to get/retrieve the current date & time in HTL (component) without writing any Sling model or Use API.
Hello - Is there a way to get/retrieve the current date & time in HTL (component) without writing any Sling model or Use API.
Hi @v1101 ,
Since sightly is also an html so in html you don't have any option to get the current date and time without using java or javascript. We have some exception in sightly like availability of global objects but again we don't have any global objects which will give you the current date and time.
So you will have to use either java or javascript to get the date and time, if you have already java implemented for the component then add one filed for the same and display on the page otherwise use javascript use API or vanila js to accomplish the same.
You can refer the below link:
https://stackoverflow.com/questions/39654779/fetch-current-time-by-using-aem-sightly
Hope this will help
Umesh Thakur
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.