You need to sign in to do that
Don't have an account?

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">
{!a.date_created__c}<br/>
{!myDate}
</apex:page>
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' );
system.debug('111111'+a.date_created__c+'2222'+myDate);
}
}
ouput:
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
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">
{!a.date_created__c}<br/>
{!myDate}
</apex:page>
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' );
system.debug('111111'+a.date_created__c+'2222'+myDate);
}
}
ouput:
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?
https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_datetime.htm#apex_System_Datetime_format_3
Thank you,
Sai
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