DateTime.Now vs. DateTime.UtcNow

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

    Also note the performance difference; DateTime.UtcNow is somewhere around 30 times faster then DateTime.Now, because internally DateTime.Now is doing a lot of timezone adjustments (you can easily verify this with Reflector).

    So do NOT use DateTime.Now for relative time measurements.

提交回复
热议问题