如何在gmt中使用时区 [英] how to use timezone with gmt

查看:176
本文介绍了如何在gmt中使用时区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何以gmt格式使用时区中的时区.

推荐答案

使用System.Core中的TimeZoneInfo 类;

为此,必须将DateTimeKind设置为DateTimeKind.Utc.

Use the TimeZoneInfo class found in System.Core;

You must set the DateTimeKindto DateTimeKind.Utc for this.

DateTime MyTime = new DateTime(1990, 12, 02, 19, 31, 30, DateTimeKind.Utc);

DateTime MyTimeInWesternEurope = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(MyTime, "W. Europe Standard Time");



请参考:在时区之间转换时间 [ C#:确保DateTime.Now返回GMT [ ^ ]



Please refer: Converting Times Between Time Zones[^]
also check similar discussion:C#: Making sure DateTime.Now returns a GMT[^]


如果您想使用格林尼治标准时间作为参考时间或想要使用相对时间,那么可能会想到最简单,最有效的方法我们使用DateTimeOffset.要使用此功能,您至少需要框架版本4.0.

http://msdn.microsoft.com/en-us/library/system.datetimeoffset.aspx [^ ]
If you want to use GMT as reference for time or you want to use relative time then parhaps the easiest and efficient way to do it us using DateTimeOffset. Bit to use this you will be needing framework version 4.0 atleast.

http://msdn.microsoft.com/en-us/library/system.datetimeoffset.aspx[^]


这篇关于如何在gmt中使用时区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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