You need to sign in to do that
Don't have an account?
Bob DeRosier
datetime format GMT
I want to change a time, where I have datetime and a timezone, to GMT (actually I want ISO8601). I the local time for an event and the timezone for it, but the conversions I tried don't change the time in GMT when the timezone changes. That is the underlying problem.
The specific problem I have is:
I have this line of code:
string modStartDT = StartDT.format(('yyyy-MM-dd\'T\'HH:mm:ss','America/New_York');
The developer guide https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_datetime.htm says that
.format(dateFormatString, timezone) is valid.
However, compiling the class produces this error for the above line
Error: Compile Error: expecting a right parentheses, found ','
I am using v38 of the SalesForce API.
If you know of another way solve my problem, I am open to that as well.
The specific problem I have is:
I have this line of code:
string modStartDT = StartDT.format(('yyyy-MM-dd\'T\'HH:mm:ss','America/New_York');
The developer guide https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_datetime.htm says that
.format(dateFormatString, timezone) is valid.
However, compiling the class produces this error for the above line
Error: Compile Error: expecting a right parentheses, found ','
I am using v38 of the SalesForce API.
If you know of another way solve my problem, I am open to that as well.
You have a extra "(" in the beginning. Make sure to have this format.
Datetime myDT = Datetime.now();
String myDate = myDT.format('h:mm a');
Thanks!
From the documentation, Constructs a Date from a String. The format of the String depends on the local date format.
date mydate = date.parse('12/27/2009');
DateTime field values are stored as Coordinated Universal Time (UTC or GMT). When a dateTime value is returned in Salesforce, it’s adjusted for the time zone specified in your org preferences.
https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_dateformats.htm (https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_dateformats.htm?search_text=UTC)
1) Company Profile: GMT+01:00
2) Convert a date using the local time or GMT time.
Local time = 15 h 20 min 45 seconds ( GMT+01:00)
GMT time = 14 h 20 min 45 seconds or
StartDT (local time) : 2017-01-07T15:20:45 (GMT+01:00) Paris
modStartDT (local time) : 2017-01-07T09:20:45 (GMT-05:00) New-York
New-York, local time = Paris, local time - 6 hours.
Best regards
Alain