Issue with Time Display in Email Velocity Script

Anonymous
Not applicable

Re: Issue with Time Display in Email Velocity Script

I think this is what you mean?

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

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

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

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

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

${myDate} 

${lead.apptBookedTime}

If not I may need to get a developer here to help me!

Anonymous
Not applicable

Re: Issue with Time Display in Email Velocity Script

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

SanfordWhiteman
Level 10 - Community Moderator

Re: Issue with Time Display in Email Velocity Script

Yes, this is what I meant by output.

SanfordWhiteman
Level 10 - Community Moderator

Re: Issue with Time Display in Email Velocity Script

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.

Nicholas_Manojl
Level 9

Re: Issue with Time Display in Email Velocity Script

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

Re: Issue with Time Display in Email Velocity Script

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

Re: Issue with Time Display in Email Velocity Script

I need to see the output generated by this code.

Output = what the tokens renders as in an email.

This is just showing me your source code, and it doesn't show me anything specific to your case.

You were showing me output above.

Anonymous
Not applicable

Re: Issue with Time Display in Email Velocity Script

Ok, I just quoted what my IT team told me was the format. I'm not technical so hence issues with understanding terminology.

I'm going to leave this here, as more complicated than I thought and will engage a developer to sort out with my IT team. Thanks for help so far.

SanfordWhiteman
Level 10 - Community Moderator

Re: Issue with Time Display in Email Velocity Script

Ok, I just quoted what my IT team told me was the format. I'm not technical so hence issues with understanding terminology.

But, you see, this doesn't make sense.

You must know the format, since all you need to do is output ${lead.apptBookedTime} from a one-line Velocity script and it's right there for you to see.

If the format changes across different leads, that's pretty bad, and would only be possible if the field is a Marketo String field.

A Marketo Datetime field will always have the same format in Velocity; it isn't possible for it to look different from lead to lead.

A String field can hold any value, including both various date-like values and and other string value. (Like the string "David Chase".)

What type of field is this in Admin >> Field Management?

I'm going to leave this here, as more complicated than I thought and will engage a developer to sort out with my IT team. Thanks for help so far.

Thing is, you're not going to find anyone who knows Velocity better than Nicho and me (it is a very niche skill).

So you don't need to go anywhere else, you need to tell us the actual, predictable input (input = the field value) so we can tell you how to output it.

Anonymous
Not applicable

Re: Issue with Time Display in Email Velocity Script

Hi Sanford and Nicho,

I am assisting David in resolving this issue. Thanks so much for your help so far.

To answer your questions above:

The 'Appt Booked Time' field is a Date/time field.

INPUT:

Screen Shot 2018-02-14 at 4.03.34 pm.png

SCRIPT:

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

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

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

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

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

OUTPUT:

Screen Shot 2018-02-14 at 4.05.01 pm.png

Our Marketo Location Settings:

Screen Shot 2018-02-14 at 4.06.08 pm.png

Let me know if you require anything else,

- Suzanne