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

how to convert datetime value from gmt to local Formated DateTime in sales force?

hai friends,in my account i have a datetime field its value is      5/30/2014 2:49 PM.
when i queried if in apex it show      Fri May 30 09:19:00 GMT 2014.
i want to disaply date time as standard  value (5/30/2014 2:49 PM) in visual force by getting apex class.(change the date format in apex class only)
for ths i tried like this

<apex:page controller="accountdatetime">

public with sharing class accountdatetime {
public account a{get;set;}
public user a1{get;set;}
public String myDate{get;set;}
public String strConvertedDate{get;set;}
public accountdatetime()
a=[select date_created__c from account where id='0019000000wD8wU'];
Datetime thisDT =a.date_created__c;
TimeZone tz=UserInfo.getTimeZone();
//myDate = thisDT.format('yyyy-MM-dd HH:mm:ss', 'PST');
//strConvertedDate = GMTDate.format('dd/MM/yyyy hh:mm:ss a', 'PST');
myDate = thisDT.format('MM/dd/yyyy hh:mm a','a.date_created__c' );


Fri May 30 09:19:00 GMT 2014
05/30/2014 09:19 AM can any one please help me to get this by using timezone,format in apes class only 

Can you try 'America/Los_Angeles' instead of PST?

Thank you,


  a=[select date_created__c from account where id='0019000000wDhQ2'];
        Datetime thisDT =a.date_created__c;
        TimeZone tz=UserInfo.getTimeZone();
        myDate = thisDT.format('M/d/yyyy hh:mm a',tz.getId());  
like this i wrote ,i got result
any how thank you saiG for your response