0

I am having the following problem. If I serialize Dates since 01-01-1970 and I deserialize them it works as expected. But for dates before 01-01-1970 the deserialization with momentjs doesn't work.

        DateTime dt = new DateTime(2010, 10, 20);
        DateTimeOffset dt2 = new DateTimeOffset(dt).ToUniversalTime();
        long a = dt2.ToUnixTimeMilliseconds();
        Console.WriteLine("value1: " + a); //1287525600000 => moment(1287525600000).toDate() => Wednesday, 20. October 2010 (00:00:00)
        DateTime dtfoo = new DateTime(1962, 10, 20);
        DateTimeOffset dtfoo2 = new DateTimeOffset(dtfoo).ToUniversalTime();
        long afoo = dtfoo2.ToUnixTimeMilliseconds();
        Console.WriteLine("value2: " + afoo); // -227239200000 => moment(-227239200000).toDate() => Friday, 19. October 1962 (23:00:00 GMT+01:00)
        Console.ReadLine();

I am deserializing the dates just with moment(unixtime).toDate(). The first date is 20-10-2010. The second date is 19-10-1962 (instead 20-10-1962).

user9923760
  • 596
  • 2
  • 8
  • 18

0 Answers0