utc

Is timezone just an offset number or “more information”?

旧时模样 提交于 2019-12-20 02:34:06
问题 I live in a country where they change the time twice a year. That is: there is a period in the year when the offset from UTC is -3 hours (-180 mins) and other period where the offset is -4 hours (-240 mins) Grafically: |------- (offset = -3) -------|------- (offset is -4) -------| start of year mid end of year My question is: the "timezone" is just the number representing the offset? that is: my country has two timezones? or the timezone includes this information? This is important because I

Converting string containing localtime into UTC in C

ぃ、小莉子 提交于 2019-12-19 08:00:51
问题 I have a string containing a local date/time and I need to convert it to a time_t value (in UTC) - I've been trying this: char* date = "2009/09/01/00"; struct tm cal = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL}; strptime(date, "%Y/%m/%d/%H", &cal); time_t t = mktime(&cal); but the time_t value I get back is the value that I would expect if the string was being parsed as UTC not local time. Maybe I have misunderstood what strptime is supposed to do, but in my timezone (UK) on the 1st September we

UTC时间

徘徊边缘 提交于 2019-12-19 07:47:59
世界的每个地区都有自己的本地时间,在Internet及无线电通信时,时间的统一非常重要! 整个地球分为二十四时区,每个时区都有自己的本地时间。在国际无线电通信中,为统一而普遍使用一个标准时间,称为通用协调时(UTC, Universal Time Coordinated)。UTC与格林尼治平均时(GMT, Greenwich Mean Time)一样,都与英国伦敦的本地时相同。UTC与GMT含义完全相同。 北京时区是东八区,领先UTC 8个小时,在电子邮件信头的Date域记为+0800。如果在电子邮件的信头中有这么一行: Date: Sun, 13 June 2010 09:45:28 +0800 说明信件发送地时间是2010年6月13号,星期日,上午9点45分28秒,该地区本地时领先UTC差 8个小时(+0800,就是东八区时间)。电子邮件信头的Date域使用24小时的时钟,而不使用AM和PM来标记上下午。 以这个电子邮件的发送时间为例,如果要把这个时间转化为UTC,可以使用以下公式: UTC + 时区差=本地时间 时区差东为正,西为负。为此,把东八区时区差记为 +0800, UTC + (+0800) = 本地(北京)时间 (1) 那么,UTC = 本地时间(北京时间))- 0800 (2) 0945 - 0800 = 0145 即UTC是当天凌晨1点45分28秒

Convert to UTC Timestamp

橙三吉。 提交于 2019-12-19 05:24:09
问题 //parses some string into that format. datetime1 = datetime.strptime(somestring, "%Y-%m-%dT%H:%M:%S") //gets the seconds from the above date. timestamp1 = time.mktime(datetime1.timetuple()) //adds milliseconds to the above seconds. timeInMillis = int(timestamp1) * 1000 How do I (at any point in that code) turn the date into UTC format? I've been ploughing through the API for what seems like a century and cannot find anything that I can get working. Can anyone help? It's currently turning it

Flask 教程:日期和时间

二次信任 提交于 2019-12-19 03:01:44
这是Flask Mega-Tutorial系列的第十二部分,我将告诉你如何以适配所有用户的方式处理日期和时间,无论他们身处地球上的何处。 显示日期和时间是Microblog应用中长期被忽略的其中一个方面。 直到现在,我也只是让Python渲染了 User 模型中的 datetime 对象,并且完全忽略了 Post 模型中的 datetime 对象。 本章的GitHub链接为: Browse , Zip , Diff . 时区地狱 使用服务器端的Python渲染日期和时间来展示到用户的浏览器并非一个好主意。考虑如下的例子, 我在2017年9月28日下午4点06分写这篇文章。我身处的时区是PDT(UTC-7),在Python解释器中运行如下: 1 >>> from datetime import datetime 2 >>> str(datetime.now()) 3 '2017-09-28 16:06:30.439388' 4 >>> str(datetime.utcnow()) 5 '2017-09-28 23:06:51.406499' datetime.now() 调用返回我所处位置的本地时间,而 datetime.utcnow() 调用则返回UTC时区中的时间。 如果我可以让遍布世界不同地区的多人同时运行上面的代码,那么 datetime.now()

How to specify that DateTime objects retrieved from EntityFramework should be DateTimeKind.UTC [duplicate]

我们两清 提交于 2019-12-18 13:54:42
问题 This question already has answers here : Entity Framework DateTime and UTC (11 answers) Closed 3 years ago . I have C# program where all DateTime objects are DateTimeKind.UTC . When saving the objects to the database it stores UTC as expected. However, when retreiving them, they are DateTimeKind.Unspecified . Is there a way to tell Entity Framework (Code First) when creating DateTime objects in C# to always use DateTimeKind.UTC ? 回答1: No, there's not. And it's actually DateTimeKind

UTC Offset in PHP

為{幸葍}努か 提交于 2019-12-18 11:07:32
问题 What's the easiest way to get the UTC offset in PHP, relative to the current (system) timezone? 回答1: date('Z'); returns the UTC offset in seconds. 回答2: // will output something like +02:00 or -04:00 echo date('P'); 回答3: timezone_offset_get() $this_tz_str = date_default_timezone_get(); $this_tz = new DateTimeZone($this_tz_str); $now = new DateTime("now", $this_tz); $offset = $this_tz->getOffset($now); Untested, but should work 回答4: I did a slightly modified version of what Oscar did. date

Current Universal time in classic asp

空扰寡人 提交于 2019-12-18 09:36:26
问题 How can I get the current time as Universal time in classic asp. I know how to get in C# and I am getting the universal time in c# with following line ((DateTime.Now).ToUniversalTime()).ToString("s") and this code gives me time like this 2012-07-09T10:29:49 But I want to know the equivalent in classic asp. Thanks 回答1: According to u229.no, there isn't any way for ASP Classic to convert to UTC. Take a look at the code the author provided below. The GetServerGMT routine will return something

UTC time to GPS time converter by Python

[亡魂溺海] 提交于 2019-12-18 08:54:36
问题 I have a UTC time (epoch Unix time) formatted as timestamp as below. 1496224620 (Human readable value: May 31, 2017 09:57:00) I need to convert the timestamp formatted as Unix time into GPS time format as below. 1180259838 (Human readable value: May 31, 2017 09:57:00) I need a python program (algorithm is fine for me) to convert timestamp formatted as Unix time to timestamp formatted as GPS time. There is one PHP program to do so. I can change from PHP code to Python code to have a Python

Python: strftime() UTC Offset Not working as Expected in Windows

泄露秘密 提交于 2019-12-18 07:32:54
问题 Every time I use: time.strftime("%z") I get: Eastern Daylight Time However, I would like the UTC offset in the form +HHMM or -HHMM. I have even tried: time.strftime("%Z") Which still yields: Eastern Daylight Time I have read several other posts related to strftime() and %z always seems to return the UTC offset in the proper +HHMM or -HHMM format. How do I get strftime() to output in the +HHMM or -HHMM format for python 3.3? Edit: I'm running Windows 7 回答1: For a proper solution, see abarnert