I just wanted to change one date string to DateTime.
However, when I try to print, he always said that the result 5/31/2009 8:00:00 AM
Any idea why this is happening?
namespace Test
{
class Test
{
static void Main()
{
Parse("5/31/2009 12:00:00 AM" );
}
static readonly string ShortFormat = "M/d/yyyy hh:mm:ss tt";
static readonly string[] Formats = { ShortFormat };
static void Parse(string text)
{
DateTime result = DateTime.ParseExact(text, ShortFormat,
CultureInfo.InvariantCulture,
DateTimeStyles.AssumeUniversal);
Console.WriteLine(result);
Console.WriteLine(result);
}
}
}
source
share