I am having trouble understanding why the value of the restored date time string is different from the original. I am writing a string in universal datetime (the format is "u", so it has a "z" at the end), but when it is restored, it differs by one hour. I use "u" to prevent this kind of thing. Can someone tell me why it is different?
I need a good string representation, because I will use the code in 5 different time zones.
Program:
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
DateTime min = DateTime.MinValue;
Console.Write("Min value date: ");
Console.WriteLine(min);
Console.Write("String: ");
string str = min.ToString("u");
Console.WriteLine(str);
DateTime dt = DateTime.Parse(str);
Console.Write("Restored Date: ");
Console.WriteLine(dt);
Console.ReadLine();
}
}
}
Conclusion:
Date of minimum value: 01/01/0001 12:00:00 m.
String: 0001-01-01 00: 00: 00Z
Recovered date: 01/01/0001 01:00:00 m.
Edit: Option to try Costa Rican culture.