获得在C#中东部时间不转换本地时间 [英] Get eastern time in c# without converting local time

查看:100
本文介绍了获得在C#中东部时间不转换本地时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道有一堆的解决方案的转换时区到时区,但想什么,我知道我们是否能够拿到东部时间未做从本地时间转换。

I know there are bunch of solutions on converting timezone to timezone, but what I'd like to know whether we can get eastern time without making conversion from our local time.

推荐答案

好yes和no,如果您代表使用GMT总是那么你没有,直到你需要出示当地需要转换。

Well yes and no, if you represent using GMT always then you don't need to convert until you need to show locality.

时间总是在GMT和服务应在GMT时区运行,因为这个原因等等。

Time is always in GMT and services should run under the GMT Timezone because of this reason among others.

接收和比GMT / UTC需要转换以外的任何存储时间。

Receiving and Storing a time in anything other than GMT / UTC requires conversions.

请注意的时区服务器也应设置为GMT的事情工作,我表示。

Please note the Timezone of the server should also be set to GMT for things to work as I indicated.

当你设置好了这个样子从而变得更加容易参考和比较不同的日历日期格式也时间和日期。

When you set things up like this it thus becomes much easier to reference and compare times and dates in different calendar date formats also.

这就是为什么日期时间抵消了它的方式到框架和SQL Server的原因。如果在一个服务器上的时区变化如此做所有存储和装载日期以本地格式不小心。

This is the reason why DateTime offset made its way into the framework and sql server. if not careful when the Timezone on a server changes so does all stored and loaded dates in local format.

一个日期比较是一个日期比较。日期时间只是包装其在蜱限定的存储器结构,使方法来访问存储器的常用部件例如一天或一年或时间或的TimeOfDay等。

A date comparison is a date comparison. DateTime just wraps a memory structure which is defined in ticks and makes methods to access commonly used parts of the memory e.g. day or year or Time or TimeOfDay etc.

此外转化才有可能,如果你知道在源SND目的地偏移,然后计算总是给出由<给出code> -1 *。(sourceOffset - destOffset)

Furthermore conversion is only possible if you know both the source snd destination offsets and then the calculation is always as given is given by -1 * (sourceOffset - destOffset)

凡在括号中的部分表示时差

Where the part in parenthesis represents the time zone difference.

这篇关于获得在C#中东部时间不转换本地时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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