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
Paul McMurrughPaul McMurrugh 

Date Always Being Displayed in GMT

Hello,
I have created a Visualforce email alert when a new event has been created. But the event time in the subject and email body don't match.

User-added image
I think it's because the time is in GMT in the email body and we are on BST in the UK now.

I have also created a custom field called 
Start Date Time Text that pulls through the date as text, formula below;

TEXT( DAY( ActivityDate ) ) & "/" & TEXT( MONTH( ActivityDate ) ) & "/" & TEXT( YEAR( ActivityDate ) ) & " " & MID( TEXT(ActivityDateTime), 12,5) 

This doesn't display correctly either, same issue?

User-added image

Anyone know how to resolve the time zone issue? Both company and user time zones are set to BST.

Thanks,

Paul
Gustavo BertolinoGustavo Bertolino
Did you check the time set in the org you're logged in by going to 'My Settings' ==> 'Personal' ==> 'Language and Time Zone'? Maybe the difference occurs because the time in the email client service is set to BST and the time in the Salesforce org you're using is set to GMT.
Paul McMurrughPaul McMurrugh
Hi Gustavo, Yes both company and user time zones are set to BST.
Alain CabonAlain Cabon
Hi,

If it is a Visualforce email, don't use a formula field to format the date but just <apex:outputText> and <apex:param>.

Date formatting example​:
<apex:page>
   <apex:outputText value="The unformatted time right now is: {! NOW() }" />
   <br/>
   <apex:outputText value="The formatted time right now is:
         {0,date,dd/MM/yyyy HH:mm z}">
       <apex:param value="{! NOW() }" />
   </apex:outputText>
</apex:page>

https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_outputText.htm

{0,date,yyyy.MM.dd G 'at' HH:mm:ss z}"> // 0 = first parameter, 1  = second parameter of type "date".
<apex:param value="{! NOW() }"          {! event.ActivityDateTime} instead of {! NOW() }