+ Start a Discussion

To Convert a datetime field to this format 'Wed Apr 18 2012 03:00:00 GMT+0530'

I have a datetime field. I want to convert it to the following format --


'Wed Apr 18 2012 03:00:00 GMT+0530'


Thanks in advance.

Shiva Ramesh @ xcdhrShiva Ramesh @ xcdhr

This example uses format to convert the date and time to the PST time zone and to format it using the specified format string.

Datetime GMTDate = Datetime.newInstanceGmt(System.Today());
String strConvertedDate = GMTDate.format('dd/MM/yyyy hh:mm:ss a', 'PST');


Thanks Shiva , But with the example that you mentioned I got a output like this -


Dt.format('E MMM dd yyyy hh:mm:ss Z', 'GMT')


Output:   Tue Apr 17 2012 01:00:00 +0100


But I want exactly like this-->   Wed Apr 18 2012 03:00:00 GMT+0530


Is this achievable?

Shiva Ramesh @ xcdhrShiva Ramesh @ xcdhr

Goto Setup-->My Personal Information-->Personal Information--> change your Locale:English(India)  and Time zone: Indochina Asia time.

If you dont want to change your locale you can do this through code. otherwise you can try it.