function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Edwin KEdwin K 

Email Template : formatted date

Hi,

 

I want to ask a question, is it possible to format the date field in Email template? Any suggestions would be great.

 

 

regards,

 

Edwin

Best Answer chosen by Admin (Salesforce Developers) 
jhurstjhurst

Edwin,

 

You can do a format, but only through a Visualforce Email Template.  With the VF Template, you can enforce a format using apex:outputText (

http://www.salesforce.com/us/developer/docs/pages/index_Left.htm#StartTopic=Content/pages_compref_outputText.htm?SearchType=Stem):

 

 

<messaging:emailTemplate subject="Testing Date" recipientType="User" relatedToType="Account">
<messaging:plainTextEmailBody >
   <apex:outputText value="The formatted Account CreatedDate is: 
         {0,date,yyyy.MM.dd G 'at' HH:mm:ss z}">
       <apex:param value="{!relatedTo.createddate}" />
   </apex:outputText>
</messaging:plainTextEmailBody>
</messaging:emailTemplate>

 This will output an email like:

 

The formatted Account CreatedDate is: 2010.08.24 AD at 16:50:19 GMT

 

 

Hope that helps.

 

Jay

All Answers

jhurstjhurst

Edwin,

 

You can do a format, but only through a Visualforce Email Template.  With the VF Template, you can enforce a format using apex:outputText (

http://www.salesforce.com/us/developer/docs/pages/index_Left.htm#StartTopic=Content/pages_compref_outputText.htm?SearchType=Stem):

 

 

<messaging:emailTemplate subject="Testing Date" recipientType="User" relatedToType="Account">
<messaging:plainTextEmailBody >
   <apex:outputText value="The formatted Account CreatedDate is: 
         {0,date,yyyy.MM.dd G 'at' HH:mm:ss z}">
       <apex:param value="{!relatedTo.createddate}" />
   </apex:outputText>
</messaging:plainTextEmailBody>
</messaging:emailTemplate>

 This will output an email like:

 

The formatted Account CreatedDate is: 2010.08.24 AD at 16:50:19 GMT

 

 

Hope that helps.

 

Jay

This was selected as the best answer
Edwin KEdwin K

Yes, that's a great help. Thanx a lot for solutions you gave me..

 

 

regards,

 

Edwin

SoloSolo

This will return tome in GMT time zone

If you want to show the same in user's time zone take a look here

 

Visualforce Email template to display date and time in User's timezone (local time)

Jose María Nicolás ArfelisJose María Nicolás Arfelis
I am looking for the same solution, but in the format dd.mm.yyyy and in user's timezone or local time. Can somebody please help?.
Satyendra RawatSatyendra Rawat
For the HTML email template the date does appear to be listed in a customer friendly format.

{!CASE(MONTH(Case.CreatedDate),1,"January",2,"February",3,"March",4,"April",5,"May",6,"June",7,"July",8,"August-",9,"September",10,"October",11,"November",12,"December","-???-")} {!DAY(Case.CreatedDate)}, {!YEAR(Case.CreatedDate)}