Today, I observed some strange behavior in the DateTime.Parse(String)
method when running on different servers. This can be observed in different online C# compilers.
My input in the yyyy-MM-ddTHH:mm:ssZ
format. Example: lets use 2020-02-12T16:57:36Z
which converted to ticks is: 637171234560000000
(converted using https://tickstodatetime.azurewebsites.net/)
This is the code I use for testing this behavior:
DateTime parsedDateTime = DateTime.Parse("2020-02-12T16:57:36Z");
Console.WriteLine(parsedDateTime + " " + parsedDateTime.Kind.ToString() + " " + parsedDateTime.Ticks);
On https://dotnetfiddle.net/akuyiI, it returns 02/12/2020 16:57:36 Local 637171234560000000
.
On https://rextester.com/XWH12209, it returns 12.02.2020 17:57:36 Local 637171270560000000
I understand that the DateTime is parsed into local timezone and displayed in local time, but why the number of ticks is also different between systems?