Date and time format in Visualforce email template. Salesforce.

Date today in Visualforce email template

Will show like: 21.01.2020

Will show like:
Time now is: 01/21/2020 3:49 PM

Date and time of move in Visualforce email template.

Why is it important to make date and time format with <apex:outputText>? Because by default the date will be shown in GMT. So, the time will not be real, it will show GMT time. Be careful with this!. But it is applicable only for email body. Email title will show correct date and time in any case.

DON’T forget to put html blank value before <apex:outputText>: to be sure to have a space between the text and the date:

Important note: You need <apex:outputText> and <apex:param> attributes only in email body or in PDF version of your visualforce template.

Code snippet for email subject:

No need extra formatting, just insert your date field and it will work directly.

Examples of date formats in Visualforce email template

The first example is my most usable version. It shows the date in GMT. Don’t forget to put <apex:outputText> and <apex:param> attributes.

Example 1:

Will show like: 28.08.2019 : 10:00

Example 2:

Will show like: 21.01.2020

Example 2.1.

Will show like: 21/01/2020

Example 3:

Will show like: 2020.01.21 GMT at 10:00:00 AM

Example 4:

Will show like: 03 Feb 2017 10:55 AM

Example 5:

Will show like: 2020.01.21 AD start: 3:49:02 GMT

Read more: Currency code format | amount insertion in Visualforce email template. Salesforce

More examples of different formats

Tuesday 1 February 2011 7.30↓

Tuesday 1 February 2011 07.30↓

1-Feb-11 7.30↓

1-Feb-11 07.30↓

1 February 2011 7.30↓

1 February 2011 07.30↓

Tuesday 1 February 2011 7.30.45↓

Tuesday 1 February 2011 07.30.45↓

1-Feb-11 7.30.45↓

1-Feb-11 07.30.45↓

1 February 2011 7.30.45↓

1 February 2011 07.30.45↓

01/02/2011 7.30↓

01/02/2011 07.30↓

01/Feb/2011 7.30↓

01/Feb/2011 07.30↓

01/02/11 7.30↓

01/02/11 07.30↓

01.2.11 7.30↓

01.2.11 07.30↓

1/2/11 7.30↓

1/2/11 07.30↓

2011-02-01 7.30↓

2011-02-01 07.30↓

01/02/2011 7.30.45↓

01/02/2011 07.30.45↓

01/Feb/2011 7.30.45↓

01/Feb/2011 07.30.45↓

01/02/11 7.30.45↓

01/02/11 07.30.45↓

01.2.11 7.30.45↓

01.2.11 07.30.45↓

1/2/11 7.30.45↓

1/2/11 07.30.45↓

2011-02-01 7.30.45↓

2011-02-01 07.30.45↓

Tuesday 1 February 2011 7.30.45↓

Tuesday 1 February 2011 07.30.45↓

1-Feb-11 7.30.45↓

1-Feb-11 07.30.45↓

1 February 2011 7.30.45↓

1 February 2011 07.30.45↓

Leave a Reply

Your email address will not be published. Required fields are marked *