Hi IDN Experts,
Is there any way to specify a customized timezone (like NZT) instead of GMT in the email template? Using the default $__dateTool only gives the date time value in GMT timezone which is not quite friendly.
Ronald
Hi IDN Experts,
Is there any way to specify a customized timezone (like NZT) instead of GMT in the email template? Using the default $__dateTool only gives the date time value in GMT timezone which is not quite friendly.
Ronald
Did you consider using Apache Velocity script to further customize your date value ?
Thanks
Krish
Hi @ronaldchuiASB , as Krishna mentioned above, you can use Apache Velocity to achieve the desired time zone.
Using DateToolâs format method, you can format your GMT time zone value to NZT time zone value. The format method (in below link) can be referred:
https://velocity.apache.org/tools/devel/apidocs/org/apache/velocity/tools/generic/DateTool.html
HTH!
Hi Krish and Gaurav,
Thanks for the suggestion. I did tried to reformat using the DateTool from velocity before I posted this thread, but not able to give desired results.
#set($_startDate = $__dateTool.toDate(âyyyy-MM-ddâTâHH:mm:ssâ, ${startDate}, Locale.US, TimeZone.getTimeZone(âPacific/Aucklandâ)))
Do you have any example to change the output to NZT time zone value? Thanks.
Ideally this would be customized to the recipient based on their identity settings for their local timezone like they see when things are presented in the UI.
Hi Ed,
Not quiteâŚ
I tried to print out the time zone using â$__dateTool.getTimeZone()â in email template it is always GMT and I cannot find any way to set to different time zone.
It will be great if you can shed some lights on how I can display the date in different time zone instead of GMT. Thanks.
Ronald
Having done a few Google-ing and finally got the solution from
sample syntax:
$dateTool.format("yyyy-MM-dd'T'HH:mm:ss", $dateTool, $dateTool.getLocale(), $dateTool.getTimeZone().getTimeZone("NZ"))
Thank you all
Ronald
@ronaldchuiASB My comment was based on how a competitor (Omada) does this. They actually look at the TZ of the intended recipient (via their user account record) and display the result in the user specific TZ vs. system TZ, admin user TZ, etc.
Hi @ronaldchuiASB , thanks for posting the solution.
We have a similar use case to convert the time zone for expiration date in certification kickoff notification. The syntax you shared is somehow not working for us, below is what we used,
$date.format(âyyyy-MM-dd HH:mm:ss.SSS a zzzzâ, $date.getDate(), $date.getLocale(), $date.getTimeZone().getTimeZone(âESTâ)) â This is taking current date to convert into EST timezone
$date.format(âyyyy-MM-dd HH:mm:ss.SSS a zzzzâ, $certification.expiration, $date.getLocale(), $date.getTimeZone().getTimeZone(âESTâ)) â This is taking expiration date to convert into EST timezone
Could you please suggest. Thanks
Not sure if Im doing anything wrong but dateTool never worked for me.
Even importing it explictly with #set($dateTool = $tool.date) doesnt do anything
@aditya_pathak , you can refer to the documentation. The â__dateToolâ is a built-in variable that we can use for date formatting.
You can then refer to the DateTool documentation for details
https://velocity.apache.org/tools/2.0/apidocs/org/apache/velocity/tools/generic/DateTool.html
@rpriya Iâm not sure why it does not work for you. Have you checked if you have provided correct value for the format function? What I can see is, the second argument I used is the $dateTool object, while you are using the date object, not sure if it is the cause.
I am using the built-in variable $__dateTool to do the formatting, not sure if your $date is the same as that. You can refer to the DateTool documentation for details
https://velocity.apache.org/tools/2.0/apidocs/org/apache/velocity/tools/generic/DateTool.html
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.