SOLVED

Email scripting datetime with AM vs. PM

Go to solution
Anonymous
Not applicable

Email scripting datetime with AM vs. PM

Hey Marketo community,

Might anyone have suggestions for adding AM vs. PM to the output of the script below. A sample of the current output is "Thursday September 1, 2016 5:00". I want to have "...5:00 AM" or "...5:00 PM". Thanks in advance for the help.

#set($dateObj = $convert.parseDate(${Milestone1_Project__cList.get(0).Customer_Approval_Call_Date__c}, 'yyyy-MM-dd hh:mm'))

## Convert to a calendar objectand perform time zone adjustments

#set($calendarObj = $convert.toCalendar($dateObj))

#if (${Milestone1_Project__cList.get(0).Time_Zone__c} == "EST")

  $calendarObj.add(10,1)

#elseif (${Milestone1_Project__cList.get(0).Time_Zone__c} == "CST") 

  $calendarObj.add(10,0)

#elseif (${Milestone1_Project__cList.get(0).Time_Zone__c} == "MST") 

  $calendarObj.add(10,-1) 

#elseif (${Milestone1_Project__cList.get(0).Time_Zone__c} == "PST") 

  $calendarObj.add(10,-2) 

#end

$date.format('EEEE MMMM d, yyyy h:mm',$calendarObj)

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Email scripting datetime with AM vs. PM

The AM/PM macro is lowercase "a".

View solution in original post

5 REPLIES 5
SanfordWhiteman
Level 10 - Community Moderator

Re: Email scripting datetime with AM vs. PM

The AM/PM macro is lowercase "a".

View solution in original post

Justin_Cooperm2
Level 10

Re: Email scripting datetime with AM vs. PM

$date.format('EEEE MMMM d, yyyy h:mm a',$calendarObj)

Anonymous
Not applicable

Re: Email scripting datetime with AM vs. PM

Thanks very much!

Sanford and Justin, do you either know of documentation resources so I can learn more about Velocity scripting?

Justin_Cooperm2
Level 10

Re: Email scripting datetime with AM vs. PM

Here are tools available in velocity along with documentation:

org.apache.velocity.tools.generic (VelocityTools 2.0-beta4 Documentation)

SanfordWhiteman
Level 10 - Community Moderator

Re: Email scripting datetime with AM vs. PM

Can't help but recommend the Velocity pieces on my blog: http://blog.teknkl.com/tag/velocity.  I have some big Velocity-related posts coming up, always with a Marketo focus.