Re: Issue with Time Display in Email Velocity Script

Subscribe
Anonymous
Not applicable

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!

25 REPLIES 25
Anonymous
Not applicable

And this is what's showing in the email

Appointment day: Friday
Appointment date: 2/02/2018

Appointment time: 12:00 AM Thu Feb 01 07:00:00 CST 2018 2018-02-01 17:00:00

Nicholas_Manojl
Level 9

Hey David,

Sanford is trying to figure out what the value is for the field of Appointment time.

I'd do the following:

1. Create a new lead "test@test.com"

2. Open up their lead record and put some time against their Appointment Booked Time field (make it 1 Jan 2018 at 12am)

3. Preview your email and change the 'View By' to "Lead" and look for "test@test.com"

4. Give Sanford the output

SanfordWhiteman
Level 10 - Community Moderator

Thanks, I also fear that this field is a string field (if it ever holds the format with the ±time zone offset), which means the format would be up to a client app to enforce.

SanfordWhiteman
Level 10 - Community Moderator

2018-02-01 17:00:00

This appears to be the value of {{lead.apptBookedTime}}.

But you said above that {{lead.apptBookedTime}} was in this format (I'm quoting you):

2015-01-06T19:15:29+11:00

You can't keep changing the premise here! Every format needs different code to parse it.

SanfordWhiteman
Level 10 - Community Moderator

Yes, this is what I meant by output.