I have a Dynamics CRM system that works across multiple timezones. The users work in their local timezones and I have some services that interact with the entities they create.
All code is done through the SDK Generated early bound entity classes.
For example:
- User creates a record with an associated task start and end date in GMT-4 timezone
- Start Date through UI = 2012/11/23 00:00:00
- Start Date in DB = 2012/11/22 20:00:00
- End Date through UI = 2012/11/25 00:00:00
- End Date in DB = 2012/11/24 20:00:00
- Services process that record and create a task with start and end dates - this time the service account is at GMT+1 (BST)
- Start Date through Code = 2012/11/22 20:00:00
- Start Date in DB = 2012/11/22 19:00:00
- End Date through UI = 2012/11/24 20:00:00
- End Date in DB = 2012/11/24 19:00:00
- User looks at created record and sees the task start and end dates are 4 hrs earlier - which when the UI renders it shows as 2012/11/22 23:00:00 where the user was expecting 2012/11/23 00:00:00.
I am seeing issues where when a user creates a record which is used by the services that the date mismatch is causing issues.
So I guess I have a number of questions:
- Is the datetime returned by the SDK EarlyBoundEntities in Local or UTC (I suspect UTC)?
- If its in UTC should my code that updates/creates records also convert the datetime I work on to UTC before setting it (i.e. use datetime.ToLocal() when getting and ToUTC() when setting)?
- Should my server adjust for daylight savings or should it stay at a set time i.e. UTC?