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
GraceWGraceW 

Need help with Event ActivityDateTime

Hi,
       I set up a new event on Salesforce GUI at    8:00 AM, 12/21/2006,  when I took a look in your stored data via the Eclipse plugin, it is stored as  Thu Dec 21 10:00:00 CST 2006.  When I query the Event, the returned string shows  2006-12-21T16:00:00.000Z.    My Time zone is CST.
      So my question is what conversion I need to do in order to correctly translate the returned string from the query?
      According to the api:

Date/time values (timestamps). Fields of this type handle date/time values (timestamps), such as ActivityDateTime in the Event object or the CreatedDate, LastModifiedDate, or SystemModstamp in many objects. Regular dateTime fields are full timestamps with a precision of one second. They are always transferred in the GMT/UTC time zone. In your client application, you might need to translate the timestamp to or from a local time zone.
       
     
So does that mean if  I set up a new event for  8:00 AM, 12/21/2006 in my client application, I need to first convert it to GMT time before I put it into new QName("ActivityDateTime"),  " yyyy-MM-ddTHH:mm:ssZ"); , and when I received something back from the query, like the above
2006-12-21T16:00:00.000Z, it is the time in GMT time zone?
       What is the tailing 000Z anyway?

       Thanks for your help.
       

 

SuperfellSuperfell
The trailing Z is the timezone specifier and means UTC. When you send dateTimes to salesforce, you need to either normalize to UTC, and indidate that it's a UTC dateTime with the Z specifier, or specify the TZ offset of the dateTime. When you read dateTimes from salesforce, you need to do the reverse if you want to show dateTimes in the users timezone. Depending on what SOAP toolkit you're using, it may or may not automatically convert between local time and UTC for you, you'd have to check the docs for your toolkit.

See ISO8601 and/or the section on the dateTime datatype in the xml schema specification for more details.
GraceWGraceW
Hi, SimonF:
         Thanks for your help!
         So for the returned string 2006-12-21T16:00:00.000Z,  can I just truncate the ".000Z", and assume that "2006-12-21T16:00:00" is the GMT time, but if I do so, I can only get  10:00am CST, not the correct  8:00am CST. Am I wrong somewhere?
        Thanks!
ad75ad75
It's over a year since this thread was active, but it still seems relevant to a problem that I'm experiencing.  I might have missed something in the docs, but I think there might be some missing useful info regarding how the SF getUserInfo().userTimeZone maps to time offsets?  If anyone can shed any light on how to solve this I would be vry grateful.

I take SimonF's point above, that when we set dateTimes through the API we need to explicitly set the time offset.  The problem is though that we don't always know the correct offset to use.  I know that might sound odd, so here's an example.

In my app the user can set a Task with a reminder.  I create the Task through the API, via code on my webserver.  When the user sets the reminder dateTime in my app's UI, they will naturally assume that they can enter a time in the timezone set in their SF user profile.  For example if a user enters a reminder time of 9:00am in my app's UI, and their salesforce user profile says that their timezone is "GMT-05:00 Eastern Standard Time America/Indianapolis", then of course the user means 9am EST not 9am UTC.  The problem is that when creating the task through the API, I can't find a way to look up the user's timezone from their SF user profile and work out what offset I need to apply, because the API only provides getUserInfo().userTimeZone as a string value (in this case the userTimeZone value would be "America/Indianapolis").  There appears to be no way to convert this string value into the required +/-hh:mm offset required.  Similarly, I can see no way to read the time offset throuugh other routes (e.g. using inline s-control params).

Clearly there is a feature somewhere within the SF system that does this timezoneString-to-timeOffset conversion implicitly.  But is that capability exposed to app developer through the API too?  I'm kind of hoping that it's there but I've just overlooked it :-)

Thanks.

PS: posters to other threads have suggested using Javascript to detect the timezone offset from the user's PC's regional settings.  This is certainly quite an inventive workaround, but in the end is not reliable.  After all, the PC's region settings might not match the timezone in the SF user profile, and some users will use more than one PC to access salesforce, not all of which might have the same region settings, and not all of which the user might be able to change.