{"action":"created","issue":{"url":"https://api.github.com/repos/Azure/azure-mobile-apps-net-server/issues/124","repository_url":"https://api.github.com/repos/Azure/azure-mobile-apps-net-server","labels_url":"https://api.github.com/repos/Azure/azure-mobile-apps-net-server/issues/124/labels{/name}","comments_url":"https://api.github.com/repos/Azure/azure-mobile-apps-net-server/issues/124/comments","events_url":"https://api.github.com/repos/Azure/azure-mobile-apps-net-server/issues/124/events","html_url":"https://github.com/Azure/azure-mobile-apps-net-server/issues/124","id":153666460,"number":124,"title":"DateTime Storage and Serialization","user":{"login":"jmichas","id":1099463,"avatar_url":"https://avatars.githubusercontent.com/u/1099463?v=3","gravatar_id":"","url":"https://api.github.com/users/jmichas","html_url":"https://github.com/jmichas","followers_url":"https://api.github.com/users/jmichas/followers","following_url":"https://api.github.com/users/jmichas/following{/other_user}","gists_url":"https://api.github.com/users/jmichas/gists{/gist_id}","starred_url":"https://api.github.com/users/jmichas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmichas/subscriptions","organizations_url":"https://api.github.com/users/jmichas/orgs","repos_url":"https://api.github.com/users/jmichas/repos","events_url":"https://api.github.com/users/jmichas/events{/privacy}","received_events_url":"https://api.github.com/users/jmichas/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-05-08T17:06:12Z","updated_at":"2016-05-08T21:24:37Z","closed_at":null,"body":"I have an issue with datetimes when they are synced from my client.\r\nI am ensuring that datetimes on my client (as displayed here https://github.com/Azure/azure-mobile-apps-net-client/issues/131) are all stored as UTC and handled as UTC in my objects since I do a lot of calculations on dates in my app.\r\n\r\nI have found an issue with my sync process though. When I sync the dates from my client and they are sent up to the server and entered into the SQL database the correct value is entered. When they are read out and sent back down it appears they are treated as Local times and so serialized into a UTC time. I am in the ET USA, so this moves the date time +4 hours. The client then displays an incorrect time to the user. Each round trip to the server for a sync on an updated object shifts the date time +4 hours. My server dates are stored as a DateTime field, should these be DateTimeOffsets instead?\r\n\r\nAlso, is there a way to simply tell the server to treat all dates read from the database as UTC and not Local?\r\n"},"comment":{"url":"https://api.github.com/repos/Azure/azure-mobile-apps-net-server/issues/comments/217747077","html_url":"https://github.com/Azure/azure-mobile-apps-net-server/issues/124#issuecomment-217747077","issue_url":"https://api.github.com/repos/Azure/azure-mobile-apps-net-server/issues/124","id":217747077,"user":{"login":"jmichas","id":1099463,"avatar_url":"https://avatars.githubusercontent.com/u/1099463?v=3","gravatar_id":"","url":"https://api.github.com/users/jmichas","html_url":"https://github.com/jmichas","followers_url":"https://api.github.com/users/jmichas/followers","following_url":"https://api.github.com/users/jmichas/following{/other_user}","gists_url":"https://api.github.com/users/jmichas/gists{/gist_id}","starred_url":"https://api.github.com/users/jmichas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmichas/subscriptions","organizations_url":"https://api.github.com/users/jmichas/orgs","repos_url":"https://api.github.com/users/jmichas/repos","events_url":"https://api.github.com/users/jmichas/events{/privacy}","received_events_url":"https://api.github.com/users/jmichas/received_events","type":"User","site_admin":false},"created_at":"2016-05-08T21:24:37Z","updated_at":"2016-05-08T21:24:37Z","body":"So, as a follow up, I expanded my test from the linked issue above and added a DateTimeOffset field.\r\nAfter posting to the server and using swagger to retrieve the record I get this:\r\n```\r\n{\r\n  \"deleted\": false,\r\n  \"updatedAt\": null,\r\n  \"createdAt\": \"2016-05-08T20:54:53.533Z\",\r\n  \"version\": \"AAAAAAANlYA=\",\r\n  \"id\": \"c771964178d247a1a7a9481e079134e7\",\r\n  \"dateTimeUtcOffset\": \"2016-05-08T20:54:49.226Z\",\r\n  \"dateTimeLocal\": \"2016-05-09T00:54:49.227Z\",\r\n  \"dateTimeUtc\": \"2016-05-09T00:54:49.227Z\"\r\n}\r\n```\r\nYou can see that the DateTimeUtc and DateTimeLocal have been shifted +4, the CreatedAt and DateTimeUtcOffset are the correct date time as created on the client. All 3 fields display the same date and time in SQL Server. So, when the mobile app server controller is serializing (I think) it is treating the value as Local so it adds 4 hours. The offset one stays the same since it explicitly tells that the offset it +0.\r\n\r\nSo, how can I tell the server to treat the DateTimes as UTC and serialize them properly? I would rather not have to go a change all my datetime fields to offsets and then rework all my client code to deal with them. I just want to add that in Mobile Services this was not an issue. The client and server projects were upgraded from the older retired Mobile Services. There should be something about DateTime in the upgrade documentation because this has become a major issue for me."}}