I noticed that when I run a SOQL query via DeveloperForce.Force (.NET), the results produced have all the DateTime fields converted in the local time zone. That is the local time zone and not the time zone of the account that I use to authenticate the client.

My questions are:

  • Where does this conversion occurs? Is it done at the server level or is it done at the level of the DeveloperForce.Force toolkit?
  • Are there any settings (in toolkit or at the server level) that can alter this behavior?

1 Answer 1


Generally speaking, the REST and SOAP APIs transfer DateTime values in the UTC Timezone. From Primitive Data Types - DateTime (my emphasis)

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 Coordinated Universal Time (UTC) time zone. In your client application, you might need to translate the timestamp to or from a local time zone.

Internally the Force.com Toolkit is using Json.NET to parse the response from the REST API. This occurs in HttpGetAsync<T>.

I found in the question How to preserve timezone when deserializing DateTime using JSON.NET? that if you changed your object property from DateTime to DateTimeOffset you could get the correct underlying UTC value.


private class Lead
    public const string SObjectTypeName = "Lead";

    public string Id { get; set; }
    public DateTimeOffset CreatedDate { get; set; }

Then when you query it you can get the underlying UTC value:

Console.WriteLine("Connected to Salesforce");

var client = new ForceClient(auth.InstanceUrl, auth.AccessToken, auth.ApiVersion);

QueryResult<Lead> leads = await client.QueryAsync<Lead>("Select Id, CreatedDate from Lead limit 10");
foreach(Lead l in leads.Records)
    Console.Out.WriteLine("ID:{0} CreatedDate:{1} ISO 8601:{2}", l.Id, l.CreatedDate, 
        l.CreatedDate.UtcDateTime.ToString("yyyy-MM-ddTHH:mm:ss.fffZ", System.Globalization.CultureInfo.InvariantCulture));

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .