You need to sign in to do that
Don't have an account?
Murali Matta
Convert only Time to GMT format
Hi,
I have custom field
Type: Time
Name:Start Time
which stores and displays the time in my local time zone(PST). How can I convert time to GMT format and display to the user?
Thanks,
Murali
I have custom field
Type: Time
Name:Start Time
which stores and displays the time in my local time zone(PST). How can I convert time to GMT format and display to the user?
Thanks,
Murali
I got the answer.
By using offset value we convert the time to GMT value.
Example: If a user in PST/PDT, and day light(PDT) offset value is -252000, Standard Time(PST) Offset value is -282000.
We can determine whether user is in PST/PDT and convert accordingly.
Thanks,
Murali
All Answers
Refer this link
https://developer.salesforce.com/forums/?id=9060G000000I1SjQAK
I have the field datatype as Time and it doesn't contain date.
Thanks,
Murali
You cannot directly convert Time to Gmt format.
You must take a datetime field and then convert it into Gmt format like this:
DateTime myDateTime = DateTime.newInstance(1993, 6, 6, 3, 3, 3);
String formatted = myDateTime.formatGMT('EEE, MMM d yyyy HH:mm:ss');
System.debug('date::::'+formatted);
Hope this explanation will help you.
Thanks.
Ajay Dubedi
But I my case I'm having only custom field Type: Time
Thanks,
Murali
If you want your output in Gmt format then I would suggest you take DateTime field instead of using Time field.
Hope this explanation will help you.
Thanks.
Ajay Dubedi
I got the answer.
By using offset value we convert the time to GMT value.
Example: If a user in PST/PDT, and day light(PDT) offset value is -252000, Standard Time(PST) Offset value is -282000.
We can determine whether user is in PST/PDT and convert accordingly.
Thanks,
Murali