Select to view content in your preferred language

Problem related dates. SDK changes dates to -3 hours everytime

3588
4
04-20-2015 06:34 AM
MarkoKangas
Deactivated User

I have problem related datetime. If I try to save date to 20.4.2015 0:00:00 it goes to database 19.04.2015.21:00:00.

Somehow SDK changes datetime to -3 hour. (My timezone is +3h to UTC)

Where I can change this behaviour? Any tips?

0 Kudos
4 Replies
dotMorten_esri
Esri Notable Contributor

The database uses UTC so that sounds about right. You can convert DateTime objects between UTC and Local using the .NET Datetime API.

DateTime.ToLocalTime Method  (System)

DateTime.ToUniversalTime Method  (System)

Also make sure you specify the DateTime.Kind correctly when creating the DateTime object.

MarkoKangas
Deactivated User

Okay I ask this more detailed. So Esri SDK makes all date values to UTC datetime. Why SDK doesn't convert those values back to related timezone?

Example I save value (UI) : 1.1.2000 0:00 GMT+3 -> Database its 31.12.1999 21:00 (Problem is bigger if DB field is on DATE)

Why SDK returns that 31.12.1999 21:00 not 1.1.2000 ?

0 Kudos
dotMorten_esri
Esri Notable Contributor

31.12.1999 21:00 UTC is the exact same date as 01.01.2000 00:00 GMT+3.

It's the job of the app you build do input and output dates in the appropriate time zone for that app.

This is just how .NET handles dates - The Runtime ensures time zones doesn't cause dates across timezones to get mixed up by always saving in UTC.

0 Kudos
MarkoKangas
Deactivated User

Okay -> Esri SDK default behaviour to unspecified Kind is UTC. Thats good to know

0 Kudos