Last Interesting Moment | Community
Skip to main content
New Participant
January 25, 2024
Solved

Last Interesting Moment

  • January 25, 2024
  • 3 replies
  • 4086 views

I am creating a couple of emails in a flow and would like to bring through a datestamp at a certain point in the flow for use as a token in one of the emails. We are using form fill as the trigger and so I have tried using the ‘Last Interesting Moment Date’ token but it keeps pulling the right date but the wrong time (usually off by a couple of hours either way). Does anyone know why this is and is there any way of fixing this or editing the code in the email so that it brings through the correct date/time? Also as a follow up question is there a way to re-format the date/time? 

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

Thanks for the help so far. I have inputted the script below and am currently getting ${date.format('EEE, MMM, d, yyyy',$myDate,$locale,$outTimeZone)} as the output. I am still looking for the re-formatted {{system.dateTime}} to reflect EEE, MMM, d, yyyy. Is there any problem with trying to re-format the system datetime? 

 

#set( $inTimeZone = $date.getTimeZone().getTimeZone('United Kingdom/London') )

#set( $outTimeZone = $date.getTimeZone().getTimeZone('United Kingdom/London') )

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

#set( $myDate = $convert.parseDate(${system.dateTime},'yyyy-MM-dd',$locale,$inTimeZone) )

${date.format('EEE, MMM, d, yyyy',$myDate,$locale,$outTimeZone)}


Is there any problem with trying to re-format the system datetime? 

Only the same problem there is trying to access any non-Velocity tokens in Velocity.

 

You’re using a syntax that doesn’t exist — but there’s also no reason to try to use that token! Velocity has its own representation of the current date.

#set( $defaultTimeZone = $date.getTimeZone().getTimeZone("America/New_York") ) #set( $defaultLocale = $date.getLocale() ) #set( $calNow = $date.getCalendar() ) $date.format("EEE, MMM, d, yyyy HH:mm", $calNow, $defaultLocale, $defaultTimeZone )

 

3 replies

SanfordWhiteman
New Participant
January 25, 2024

The times aren’t “off”, they’re just in a timezone other than the one you want. Velocity {{my.tokens}} can switch timezones for you, search past posts on the topic.

Darshil_Shah1
Community Manager
January 25, 2024

Interesting! IMHO, the token should print as-is, unless you have them in different timezones than you want! The Last Interesting Moment Date, similar to other interesting moment standard fields, is a system-managed standard field that should ideally get updated by the system and should be pulled as-is when referenced via its token. I'd check with support if you keep seeing discrepancies in the data you see on the person info in the DB and in the email when referenced via the token (given that you have verified the potential difference due to timezones- i.e., the date time being in different timezone than you expect). Re the date format change, there are plenty of posts around that already in the community if you search.

New Participant
January 25, 2024

For your first question, I have never had this issue and can't find anything online. But I wanted to put in my 0.02c 🙂 

 

In this situation, I'd rather use a custom string field with a flow step to change the data value to the {{system.datetime}} token. I'm not sure what your instance looks like, but we use interesting moments in a lot of different campaigns. Having a dedicated field for the flow would make me sleep better at night than using Last Interesting Moment Date.

 

Lastly, you can use Velocity to change your date/time. Note that I am not using Last Interesting Moment Date, so I'm unsure what Velocity can pull in terms of Interesting Moments. If you're interested in creating a custom field, I've actually shared my the code that I use on Marketing Nation!

 

TomMe4Author
New Participant
January 25, 2024

Thanks! The datetime is working brilliantly, I’m now struggling to adjust the formatting. 

    

<span style="font-size: 12px;"><strong>Sent:&nbsp;<span style="color: #000000; font-family: arial, helvetica, sans-serif; font-size: 12px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 300; letter-spacing: normal; orphans: 2; text-align: left; text-indent:

0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: #ffffff; float: none; display: inline !important;">{{system.dateTime}}</span></strong></span>

 

I am a complete novice when it comes to coding. I have looked at the code for my email template and above is the section which references system.dateTime. Instead of the format YYYY-MM-DD hh:mm:ss I would like Day, Month DD YYYY hh:mm. Is this something that you can help with? 

New Participant
January 26, 2024

@tomme4  You should create a new velocity script token and use the new timestamp field that you created in your velocity script that I posted in the previously linked thread. Here it is below too! 

 

 

#set( $inTimeZone = $date.getTimeZone().getTimeZone('America/New_York') ) #set( $outTimeZone = $date.getTimeZone().getTimeZone('America/New_York') ) #set( $locale = $date.getLocale() ) #set( $myDate = $convert.parseDate(${lead.Your Token Here},'yyyy-MM-dd',$locale,$inTimeZone) ) ${date.format('MMMM dd, yyyy',$myDate,$locale,$outTimeZone)}

 

 

This script will only output your datetime field as MM DD, YYYY. I believe if you wanted the day of the week, you'd format it like this, according to what I've seen online:

$date.format('EEE, MMM d, yyyy', $myDate,$locale,$outTimeZone)}

I haven't had the time to test this in my instance though 🙂