DateTime.Now vs. DateTime.UtcNow

后端 未结 13 1474
暗喜
暗喜 2020-11-28 17:43

I\'ve been wondering what exactly are the principles of how the two properties work. I know the second one is universal and basically doesn\'t deal with time zones, but can

13条回答
  •  [愿得一人]
    2020-11-28 18:20

    DateTime.UtcNow is a continuous, single-valued time scale, whereas DateTime.Now is not continuous or single-valued. The primary reason is Daylight Savings Time, which doesn't apply to UTC. So UTC never jumps forward or back an hour, whereas local time(DateTime.Now) does. And when it jumps backward, the same time value occurs twice.

提交回复
热议问题