Convert Date/Time as per User's Timezone | Community
Skip to main content
Level 2
June 15, 2022
Question

Convert Date/Time as per User's Timezone

  • June 15, 2022
  • 1 reply
  • 1431 views

Hello Everyone,

 

We are using below velocity script in the token created for a custom object which has date as data type. Based on user's location, out time zone will be updated with Country/City to populate exact date in the email communication sent to users. It populates correct date for the countries we checked but only for Canada, the populated date is not matching with user's data. If user data is 29/03/2022 1:45 AM, it populates as 28/03/2022 3:15 PM. In velocity script, America/Toronto is updated in out time zone as below for Canada user and tried updating with different cities as well, still getting data mismatch issue. Any suggestions to populate data as expected?

Velocity Script: 

#foreach( $Application in $sorter.sort($application_cList,['bookingDate:desc'])) #if($foreach.count<=1) #set($inTimeZone=$date.getTimeZone().getTimeZone('America/Chicago')) #set($outTimeZone=$date.getTimeZone().getTimeZone('America/Toronto')) #set($locale=$date.getLocale()) #set($myDate=$convert.parseDate(${Application.bookingDate},'yyyy-MM-dd',$locale,$inTimeZone)) ${date.format('MMMM dd, yyyy',$myDate,$locale,$outTimeZone)} #end #end


Regards,
Srivignesh B.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

Jo_Pitts1
Community Advisor
Community Advisor
June 15, 2022

@srivignesh ,

what do you mean by a 'data mismatch issue'.

What output are you getting.

 

regards

Jo

Level 2
June 16, 2022

@jo_pitts1  Thanks for your response. The user data in the system is 29/03/2022 1:45 AM and the output populates as 28/03/2022 3:15 PM instead of showing 29/03/2022.

Thanks,

Srivignesh B.