1

I'm really confused in timezones.

All the DateTime fields I fetch from the CRM-Soap-Service are set to the local client timezone. For instance +1 for Central Europe Standard Time.

But users can set their own TimeZone in Dynamics CRM, so I have to convert the local TimeZone, retrieved by Service to the users setting TimeZone (for instance (GMT-06:00) Central America)

All meta data of the users setting for TimeZones I can fetch from CRM are:

{
    "name": "timezonecode",
    "type": "Int32",
    "value": "256"
},
{
    "name": "userinterfacename",
    "type": "String",
    "value": "(GMT+10:00) Canberra, Melbourne, Sydney (Commonwealth Games 2006)"
},
{
    "name": "standardname",
    "type": "String",
    "value": "Canberra, Melbourne, Sydney (Commonwealth Games 2006)"
},
{
    "name": "timezonebias",
    "type": "Int32",
    "value": "360"
},
{
    "name": "timezonedaylightbias",
    "type": "Int32",
    "value": "-60"
},

Dynamics CRM doesn't provide me well formed meta data to simply convert the current timezone. Maybe I can handle with setMinutes() of the Date() object, but that does not change the TimeZone in the Object itself. It's still (GMT +1) though I added 180 Minutes.

moment.js is allowed :-)

Patrik
  • 1,119
  • 5
  • 18
  • 37

1 Answers1

1

I don't believe what you said above is correct. If you are using CRMSDK then all datetime values are returned as UTC. The SDK accepts both Local or UTC time for creates and updates. This article provides a good insight into how CRM handles dates and times: http://develop1.net/public/post/Dynamics-CRM-DateTimes-the-last-word.aspx

Just be careful if you are updating date time fields via the SDK DateTime.Now will return local time (with timezone offset) to that can sometimes get confusing.

In my experience the best approach with CRM is to always leave dates and time as universal time and let the browser convert to local time.

Convert UTC date time to local date time using JavaScript

You could always retrieve the users timezone settings from CRM (http://missdynamicscrm.blogspot.com.au/2015/04/get-current-user-setting-timezone-crm-c.html) and convert the UTC time from CRM to local time as a strategy of last resort.

Community
  • 1
  • 1
Malachy
  • 307
  • 8
  • 16