2

I am doing some freelance work for a client and they are adamant about translating a date/time a user puts in back to CST (Central Standard Time) for one of the fields displaying in the email. This is what the email currently looks like:

Internal Deadline: <apex:outputText value="{0,date,MM/dd/yy HH:mm a}"><apex:param value="{!relatedTo.Internal_Deadline__c}" /></apex:outputText>

RFP Deadline: <apex:outputText value="{0,date,MM/dd/yy HH:mm a}"><apex:param value="{!relatedTo.RFP_Deadline__c}" /></apex:outputText>

I want to take the value for that field input by the user in their time zone since they have users in different countries as well and translate it to CST. Does anyone know how I can code this?

1 Answer 1

1

if you want specific Time zone, i would prefer formatting date in APex side instead of visualforce. in visual force side you can formatted only to GMT format like as shown below. your Apex controller return relatedTo object with Internal_Deadline__c & RFP_Deadline__c date fields so you need convert in Apex as shown in below code

GMT format at Visualforce side

<apex:outputText value="{0,date,yyyy.MM.dd G 'at' HH:mm:ss z}">
       <apex:param value="{!relatedTo.RFP_Deadline__c}" />
   </apex:outputText>

Convert CST format in APEX

relatedTo.Internal_Deadline__c .format('HH', 'CST');
relatedTo.RFP_Deadline__c .format('HH', 'CST');

CST is Timezone Id, can find different Time zone Id's here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .