English 中文(简体)
格林纳达
原标题:php DateTimeZone->getOffset() returns invalid offset for GMT timezones

Hopefully someone notices what is the cause for the problem I m having.

在其他所有时间区,例如“欧洲/赫尔辛基”的计算结果如下:正确的数值,但出于某种原因,我对Etc/GMT+2风格的时间区和反之亦然(例如,Etc/GMT-2I获得积极价值,7200)。

$dateTimeZone = new DateTimeZone( Etc/GMT+2 );
echo $dateTimeZone->getOffset(new DateTime("now", new DateTimezone(  UTC  )));

Expected: 7200 Result: -7200

问题回答

<代码>Etc/GMT+2 时区是指否则将称作“GMT -2”或如<代码><日期时间与幅度;-02:00。

这是因为PPOSIX代表了这些时间区:

这笔冲销具体指明了你必须增加当地时间,以取得协调的普遍时间价值。 它有类似于[+->h[:[s]]]。 如果当地时间区位于梅里德南以西,如果是东部,情况就是积极的。 时间为0至23小时,时间为0至59分。

TZ Variable。

而且:

北极时间区缩略语通常在美洲金枪鱼委以东数小时,例如日本+09和夏威夷10小时。 然而,PPOSIX TZ环境变量使用了相反的公约。 例如,日本和夏威夷可能分别使用TZ=“JST-9”和TZ=“HST10”。 如果具备茨数据库,通常最好利用TZ=“亚洲/东京”和TZ=“太平洋/Honolulu”等环境,因为这样可以避免混乱,更好地处理旧的邮票,使你能够更好地摆脱今后对规则的任何变化。 永远不应将PPOSIX TZ设定为“GMT-9”等值,因为这样会错误地声称,当地时间比UTC提前9小时,时间区被称为“GMT”。

From Sources for Time Zone and Daylight Saving Time Data - Time notation.

http://www.php.net/manual/en/timezones.others.php#64310"rel=“nofollow”http://www.php.net/manual/en/timezones.others.php#64310

附加和减标(+/-)不是直觉的。 例如,

"Etc/GMT-10" actually refers to the timezone "(GMT+10:00) Canberra,Sydney,Melbourne".





相关问题
Weird Time Issue in Python

Problem with using times in Python. Terminal > Python >>> calendar.timegm(datetime.datetime.now().utctimetuple()) 1258449380 This time indicates GMT: Tue, 17 Nov 2009 09:16:20 GMT Eclipse ...

How does a .NET process get the culture information?

I have a Windows service running (C#, .NET 2.0) on Windows Server 2003 R2. In one server the System.Threading.Thread.CurrentThread.CurrentCulture is {en-AU} and in the other {en-US}. This has caused a ...

Best way to get maximum Date value in java?

I m writing a bit of logic that requires treating null dates as meaning forever in the future (the date in question is an expiration date, which may or may not exist). Instead of putting in special ...

Date format in SQL Server

Short Question: What s the best date format to use in SQL Server? Long Explanation: We re converting our database from mysql to SQL Server. In mysql we always used int(11) to avoid the daylight ...

Converting asp.net/sql web app to be ime zone savy

Our current app stores all dates via the server s datetime. I m thinking we need to update all datetime values in the database over to UTC time. Now for displaying these dates back to the user, I ...

Check if string is of SortableDateTimePattern format

Is there any way I can easily check if a string conforms to the SortableDateTimePattern ("s"), or do I need to write a regular expression? I ve got a form where users can input a copyright date (as a ...

DateTime in PropertyGrid in .Net

I m currently working on some DateTime properties in a PropertyGrid in c#.Net. Im using the default drop-down datetime picker. My question: Is there any way to show the full date with the time? By ...

热门标签