Issue with Time Display in Email Velocity Script | Community
Skip to main content
February 1, 2018
Question

Issue with Time Display in Email Velocity Script

  • February 1, 2018
  • 1 reply
  • 5843 views

Launched Marketo in Nov-16 and during implementation a couple of MyTokens were set-up using Velocity script to convert dates and times, to our local timezone Australia/Sydney:

  • {{my.Appt Date}}   - for the clients appointment date with consultant
  • {{my.Appt Date Time}}    - for appointment time with consultant (the actual field it references also includes the date)

The date token is working fine, but the time token is displaying 7 hours later than it should be, (e.g. 5pm instead of 10am). The date and time are pulled from separate Fields in the database.

This is the script that's being used:

#set( $inTimeZone = $date.getTimeZone().getTimeZone('Australia/Sydney') )

#set( $outTimeZone = $date.getTimeZone().getTimeZone('Australia/Sydney') )

#set( $locale = $date.getLocale() )

#set( $myDate = $convert.parseDate(${lead.apptBookedTime},'yy-MM-dd HH:mm',$locale,$inTimeZone) )

${date.format('hh:mm a',$myDate,$locale,$outTimeZone)}

I don't have much experience with Velocity, did a bit of reading online, but can't work out why the above would be showing the time incorrectly.

Can anyone help me solve? Thanks in advance!

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

1 reply

SanfordWhiteman
New Participant
February 1, 2018

Is the field apptBookedTime truly storing the datetime in your local tz, or is it storing it in UTC?

What do you see if you output

${lead.apptBookedTime}

And what do you mean by

The date and time are pulled from separate Fields in the database.

I only see one Lead (Person) field in your code, ​apptBookedTime.

Also, please highlight code using the Advanced Editor's syntax highlighter (you can select Java for Velocity):

February 5, 2018

apptBookedTime is stored in local time zone

${lead.apptBookedTime} is also showing 5pm

Please ignore the separate fields comment.

I'm not sure where to access the advanced editor in order to highlight - is this something I need to download?

SanfordWhiteman
New Participant
February 6, 2018

I need to know the full, exact string format. Assuming it's not just the 3 characters "5pm".

For the editor, you don't need to download anything, you have to find the link for Advanced Editor to the upper right of the regular editor.