Datetime.Today in GMT in C#

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10802371/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-09 15:18:55  来源:igfitidea点击:

Datetime.Today in GMT in c#

c#datetimetimezone

提问by Tony

I want to convert DateTime.Todayto GMT time.

我想转换DateTime.Today为 GMT 时间。

i.e. If I am in L.A. and it is 11pm of 22/02/2012 I want DateTime.Today to be 23/02/2012 because it will be that day in GMT time.

即,如果我在 LA 并且现在是 22/02/2012 的晚上 11 点,我希望 DateTime.Today 是 23/02/2012,因为它将是格林威治标准时间的那一天。

采纳答案by Carsten Schütte

There is no DateTime.UtcToday, but you can try DateTime.UtcNow.Date

没有DateTime.UtcToday,但你可以试试DateTime.UtcNow.Date

回答by rirajat

DateTime.UtcNowwill give you the current universal time.

DateTime.UtcNow将为您提供当前的世界时。