You need to sign in to do that
Don't have an account?
liwu
inputField DateTime format
One of the columns in my apex:dataTable is displaying a DateTime field. I do this like so:
<apex:column > <apex:facet name="header">Date</apex:facet> <apex:outputText value="{0,date,yyyy-MM-dd HH:mm:ss}"> <apex:param value="{!MyObj.MyDate__c}" /> </apex:outputText> </apex:column>
The problem I have is that this date is being displayed in GMT and not the timezone of my login (BST). Is there a way to adjust this?
On a sidenote, if I use this same MyObj.MyDate__c field in an apex class and do something like:
MyObj.MyDate__c.format('yyyy-MM-dd HH:mm:ss')
It does format into my own timezone (BST)
You can use a wrapper class in your controller to hold each record and the formatted date.
Controller:
public class my controller{
public class myObjectWrapper{
public String formatDate{get; set;}
public MyObject__c obj{get; set;}
public myObjectWrapper(MyObject__c obj){
this.obj = obj;
formatDate = obj.MyDate__c.format(yyyy-MM-dd HH:mm:ss);
}
}
}
Page:
<apex:column >
<apex:facet name="header">Date</apex:facet>
<apex:outputText value="{!obj.formatDate}">
</apex:outputText>
</apex:column>