Adding Seconds to DateTime with a Valid Double Results in ArgumentOutOfRangeException

前端 未结 7 1239

The following code crashes and burns and I don\'t understand why:

DateTime dt = new DateTime(1970,1,1,0,0,0,0, DateTimeKind.Utc);
double d = double.Parse(\"1         


        
7条回答
  •  无人共我
    2021-01-17 10:54

    In my case I had to consume an api object as a double and convert the unix time to a DateTime:

    DateTime Date = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(Double.Parse("1596225600000"));
    

提交回复
热议问题