How can I convert a Unix timestamp to DateTime and vice versa?

前端 未结 19 2414
抹茶落季
抹茶落季 2020-11-21 06:37

There is this example code, but then it starts talking about millisecond / nanosecond problems.

The same question is on MSDN, Seconds since the Unix epoch in C#<

19条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-21 06:53

    A Unix tick is 1 second (if I remember well), and a .NET tick is 100 nanoseconds.

    If you've been encountering problems with nanoseconds, you might want to try using AddTick(10000000 * value).

提交回复
热议问题