I have a email alert that uses a Visualforce email template to generate an email with a date/time field that I want my to display as GMT, currently the time displayed in the email is offset by the hours credit or deficit based on the timezone of the user that triggered the email alert through a workflow.) What do I need to change in order to rectify this?

<p>Date of completion <apex:outputtext value=" {!Relatedto.Completion_Date__c}"/>.</p>


   <apex:outputText value="{0,date,yyyy.MM.dd 'at' HH:mm}">
   <apex:param value="{!Relatedto.Completion_Date__c}}" />

^ = 2015.01.06 at 14:43

2 Answers 2


You can use Value property of apex:outputText tag to specify the GMT format like this.

   <apex:outputText value="The formatted time right now is: 
         {0,date,yyyy.MM.dd G 'at' HH:mm:ss z}">
       <apex:param value="{!NOW()}" />
  • Would it look something like what I have put in above as a possible solution?
    – Bartley
    Jan 6, 2015 at 14:05
  • I tested that and got it to convert it to GMT which is great, the only thing to note is that it returns the date and time in the format: 2015.01.06 AD at 14:43:00 GMT this is a little unfriendly to the reader.
    – Bartley
    Jan 6, 2015 at 15:04
  • The G defines the era (as in AD or BCE) and does not define GMT - see docs.oracle.com/javase/7/docs/api/java/text/…. You can remove the :ss if you don't want to show seconds. A useful tool is fileformat.info/tip/java/simpledateformat.htm
    – cropredy
    Jan 6, 2015 at 20:38
  • how to achieve the same for <apex:input> field Feb 2, 2016 at 5:14

Convert "Data-Time" DataType to "String" and Salesforce Platform automatically takes care of the Time-Zone Conversion to User Specific Time-zone.

enter image description here

  • True that ! thanks for this info - if we do not want that, am concatenating an empty string : string unFormattedDateTime = '' + System.Now();
    – peevesy
    Jul 14, 2016 at 20:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.