utc

Python: How to get UTC time given TIMEZONE

◇◆丶佛笑我妖孽 提交于 2019-12-11 02:18:19
问题 I am in the US and I want to get the UTC time (without the effect of Daylight Saving Time) for a piece of code: localtime = strftime("%m%d%y%H%M", gmtime()) Right now that code give me time in Greenwich, England. I know that I have a time offset of -8 (GMT -8). How can I get the UTC time to a specific timezone? (using Python library, not casting the hour to integer, - 8, and than convert it back) Thank you. 回答1: Try the datetime module: datetime.datetime.utcnow() + datetime.timedelta(hours=-8

Gmt php or UTC C# equivalence through SOAP

余生长醉 提交于 2019-12-10 23:38:46
问题 is C# DateTime.UtcNow and php date("c") are equivalent I doubt because when I soap both I get from C# : <dateDebutAction xsi:type="xsd:dateTime">2012-03-20T16:01:28.3954818Z</dateDebutAction> and from PHP : <dateDebutAction xsi:type="xsd:dateTime">2012-03-20T16:04:29+00:00</dateDebutAction> if they are not equivalent what is the C# for date("c") context : I send the first soap to someone who work in PHP, and he's saying me the date is not valid, he gave me an exemple in php with date("c") and

Javascript Date Gives me EDT but I want EST

扶醉桌前 提交于 2019-12-10 23:37:29
问题 I am receiving a MySQL Timestamp in UTC and trying to covert it to the client's local timezone. However, When i do this I get the wrong time zone. Ive formatted my DateTime String to be: var utcTime = 2014-05-15T13:00:00Z However when after my conversion my dateObject is: Date {Thu May 15 2014 09:00:00 GMT-0400 (EDT)} . However, I want my Timezone to be GMT -0500 (EST). I've searched online and saw there is a way to do this by appending "UTC" to a MYSQL formatted Timestamp.. However, this

NSDateFormatter Trouble?

醉酒当歌 提交于 2019-12-10 23:16:52
问题 I am trying to parse an RSS feed, but the date is hard to parse. The date string is: publishedDate = "2013-01-08T20:09:02.000Z" Here is my code: NSDateFormatter *utc = [[NSDateFormatter alloc] init]; [utc setTimeZone:[NSTimeZone timeZoneWithName:@"UTC"]]; [utc setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss'Z'"]; NSDate *dtUTC = [utc dateFromString: publishedDate]; NSDateFormatter *dfLocal = [[NSDateFormatter alloc] init]; [dfLocal setDateFormat:@"yyyy-MM-dd"]; [dfLocal setTimeZone:[NSTimeZone

Is it possible to get a timezone in Python given a UTC timestamp and a UTC offset?

六眼飞鱼酱① 提交于 2019-12-10 18:39:44
问题 I have data that is the UTC offset and the UTC time. Given that, is it possible in Python to get the user's local timezone (mainly to figure if it is DST etc. probably using pytz), similar to the function in PHP timezone_name_from_abbr ? For example: If my epoch time is 1238720309, I can get the UTC time as: >>> d = datetime.utcfromtimestamp(1238720309) >>> print d + dt.timedelta(0,-28800) #offset for pacific I think 2009-04-02 17:04:41.712143 This is correct except it is PDT right now, so it

why is LINQ to SQL tricked by an extension method? what now?

强颜欢笑 提交于 2019-12-10 18:14:41
问题 Consider my Event class, and that i store DateTime 's in the DB as UTC dates. I simply want to return a filtered range based on the current date in a particular time zone - easy right? This works fine: IQueryable<Event> test1 = this.GetSortedEvents().Where(e => e.FinishDateTime.Date >= DateTime.UtcNow.Date); This also works fine: IQueryable<Event> test2 = this.GetSortedEvents().Where(e => e.FinishDateTime.AddHours(3).Date >= DateTime.UtcNow.AddHours(3).Date); .. and additionally meets my time

【转】设置CentOS系统时区为上海

浪尽此生 提交于 2019-12-10 17:12:26
GPS 系统中有两种时间区分,一为UTC,另一为LT(地方时)两者的区别为时区不同,UTC就是0时区的时间,地方时为本地时间,如北京为早上八点(东八区),UTC时间就为零点,时间比北京时晚八小时,以此计算即可 UTC:世界协调时间(Universal Time Coordinated,UTC) CST:中国沿海时间(北京时间)(China Standard Time UTC+8:00) 在安装完CentOS系统后发现时间与现在时间相差8小时,这是由于我们在安装系统的时选择的时区是上海,而CentOS默认bios时间是utc时间,所以时间相差了8小时。这个时候的bios的时间和系统的时间是不一致的,一个代表 utc 时间,一个代表cst(+8时区),即上海时间。 下面是同步时间的解决方法: 1、vi /etc/sysconfig/clock #编辑文件 ZONE="Asia/Shanghai" UTC=false #设置为false,硬件时钟不于utc时间一致 ARC=false    2、 linux的时区设置为上海 ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime    3、 对准时间,需要先安装ntp服务器 yum install ntp (如果这句执行不成功、直接修改显示时间也行) yum -y install

utc seconds since midnight to datetime

随声附和 提交于 2019-12-10 14:46:21
问题 I'm getting radar data as "tracks" and the track data indicates the number of UTC seconds since the last midnight, apparently. This is not the number of seconds since the 1st of jan 1970. Now I want to convert that to date time, knowing that the clock on the computer could be slightly out of sync with the clock on the radar. I'll assume the radar's seconds are the reference, not the computer's. I want to convert these seconds to a full date time. Things seem to be a little tricky around

DateTimeConverter converting from UTC string

試著忘記壹切 提交于 2019-12-10 13:29:22
问题 I have a date serialized as a string "2012-06-20T13:19:59.1091122Z" Using the DateTimeConverter, this gets converted to a DateTime object {22:49:59.1091122} with the Kind property set to "Local". eg. The following test fails: private static readonly DateTime UtcDate = new DateTime(634757951991091122, DateTimeKind.Utc); private const string UtcSerialisedDate = "2012-06-20T13:19:59.1091122Z"; [Test] public void DateTimeConverter_Convert_From_Utc_String() { // Arrange var converter =

Why should I use UTC?

﹥>﹥吖頭↗ 提交于 2019-12-10 13:02:40
问题 Our app currently uses a local time rather than UTC. I know that it's important to use UTC, but cannot for the life of me remember why. Assuming that the DateTimes are stored with an offset, when comparing a local time to a UTC time, or with another time with a different timezone, surely any library worth using will know about the different timezones and mutate the two objects into something that can be compared? As long as the offset is passed around with the DateTime (which it will be using