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:
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!
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
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
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.
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.
Yes, this is what I meant by output.