获取当前GMT时间时间、GMT

2023-09-02 10:55:20 作者:慌言☆的☆世界

有没有在C#中的方法,该方法返回UTC(GMT)时区?不是基于系统的时

Is there a method in C# that returns the UTC (GMT) time zone? Not based on the system's time.

基本上我想要得到正确的UTC时间,即使我的系统时间是不正确的。

Basically I want to get the correct UTC time even if my system time is not right.

推荐答案

而不是调用的

DateTime.Now.ToUniversalTime()

您可以致电

DateTime.UtcNow

同样的事情,但更短的:)文档。

Same thing but shorter :) Documentation here.