Date Token Appearance | Community
Skip to main content
May 9, 2014
Question

Date Token Appearance

  • May 9, 2014
  • 5 replies
  • 3881 views
Can you alter the way a Date Token appears? It is displaying on the Date Token itself as Jun 5, 2014 but when the token is inserted into an email, it's previewing as 2014-05-05. I want the final appearance to be Month, Day, Year. Is this possible? 
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

5 replies

May 12, 2014
It's a bit of extra work but if you use My.Token in a program you can use the email scripting option to transform the date as you wish. 

program -> My tokens -> Email Script 
Name token 
Then copy and paste the code below into the editor, replacing "your_field" with the name of your date field

$date.format("MM/dd/yyyy", $convert.parseDate(${lead.your_field}, "yyyy-MM-dd"))
September 6, 2016

I used your code to create My Token in the Program:

$date.format("MM/dd/yyyy", $convert.parseDate(${lead.WarrantyExpirationDate}, "yyyy-MM-dd"))

I applied this in the html body:

{{my.WarrantyExpirationDateFormatted}}

The email displayed the code literally.

What's missing?

SanfordWhiteman
Level 10
September 6, 2016
  1. Ensure you have checked off the lead.WarrantyExpirationDate field for inclusion in the Velocity script.
  2. You should always take timezones into account, even for strings that appear to be only dates.  Date objects always have timezones and this can cause unexpected (and not in a good way) results.
  3. See my responses tp Get time from timestamp andSet local timezone using Velocity scripts
May 12, 2014
I did the above setps. Named the Email script token Date_Converter. I leave the Webcast_Date token there, yes? And replaced the "your_field" in the code with "Webcast_Date". It's not changing anything in the email asset when previewed. Date still reads "yyyy-MM-dd" and not how I'd like it to ready which is "MM/dd/yyyy". Do I need to insert the Email script token I just created "Date_Converter" into the email asset? I did try inserting it in the email asset and it didn't do anything. Does this email script run from the token campaign page without needing to insert it anywhere?
November 7, 2014

I understand the script token needs to be inserted in lieu of the date token, but I'm getting an error using my date token in the code provided above:

I defined a date toke: {my.event date}
But $date.format("MM/dd/yyyy", $convert.parseDate(${my.event date}, "yyyy-MM-dd")) causes an error when sending the email.

September 8, 2015

Did you find an answer to using {my.event date}? We are also having a problem using the date token.

April 24, 2015

I don't think you can nest operations like you're trying to do in the code snippet you provided. I was able to accomplish this by setting a variable and using it as an input to the outer operation:

#set($str = $convert.parseDate(${lead.HEye_Trigger_Expire__c}, "yyyy-MM-dd"))
$date.format("MM/dd/yyyy",$str)


Here's where I got the idea:
http://stackoverflow.com/questions/22150952/string-to-date-with-convert

May 8, 2015
This worked perfectly for me. Thanks!