DateTime.Now vs. DateTime.UtcNow

后端 未结 13 1476
暗喜
暗喜 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:39

    The "simple" answer to the question is:

    DateTime.Now returns a DateTime value representing the current, system time (in whatever time zone the system is running in). The DateTime.Kind property will be DateTimeKind.Local

    DateTime.UtcNow returns a DateTime value representing the current Universal Co-ordinated Time (aka UTC) which will be the same regardless of the system's time zone. The DateTime.Kind property will be DateTimeKind.Utc

提交回复
热议问题