获取当前GMT时间 [英] Getting current GMT time

查看:737
本文介绍了获取当前GMT时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有在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

同样的事情,但更短的:)文档 href="http://msdn.microsoft.com/en-us/library/system.datetime.utcnow.aspx">。

Same thing but shorter :) Documentation here.

这篇关于获取当前GMT时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆