Activity Forums Salesforce® Discussions Can any one provide a code snippet for displaying the date time value on visualforce page

  • Abhinav

    Member
    May 31, 2016 at 3:33 pm

    Hi Ajit,

    Please use the below snippet. I hope this will solve the issue.

    <apex:page controller="TimeZoneController">
    <apex:outputText value="{0,date,dd/MM/yyyy HH:mm:ss}">
    <apex:param value="{!NOW()+offset}"/>
    </apex:outputText>
    </apex:page>

    public class TimeZoneController{
    public Double offset{get{
    TimeZone tz = UserInfo.getTimeZone();
    //Milliseconds to Day
    return tz.getOffset(DateTime.now()) / (1000 * 3600 * 24.0);
    }}
    public TimeZoneController(){
    }
    }

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos