Time Zones

2019-07-03 02:05发布

I know this isn't specific to PHP, but what's the point of using timezones listed like this :http://us2.php.net/manual/en/timezones.america.php? For example "America/Indianapolis" and "America/New_York". What is the problem with EST, EDT, CST, CDT, &c?

标签: php timezone
6条回答
疯言疯语
2楼-- · 2019-07-03 02:32

"America/Indianapolis" and "America/New_York" are called TZID (Timezone Identifier) from the tz database (also called zoneinfo database or IANA time zone database or Olson database).

The tz database partitions the world into regions where local clocks have all been the same since 1970.

This means that when specifying a TZID, you can accurately and without ambiguity date any local event in the world occurring since 1 January 1970 (Unix Epoch).

This may seem convenient together with a Unix timestamp. Yet, beware of 32 bits programs as they will report negative values with the year 2038 problem.

"EST", "EDT", "CST" and "CDT" are often abbreviations of The Microsoft Windows Time Zone Database and lead to ambiguities as they aren't unique (compare "Central Standard Time", "Central Summer Time", "China Standard Time" and "Cuba Standard Time").

More advantages/disadvantages are given on https://stackoverflow.com/tags/timezone/info.

查看更多
姐就是有狂的资本
3楼-- · 2019-07-03 02:42

All regions within a timezone don't follow the same rules. For example, Arizona does not observe Daylight Saving Time.

查看更多
淡お忘
4楼-- · 2019-07-03 02:46

'America/New_York' doesn't depend on the date. EST is only valid in winter, while in summer you have to change it to EDT. Other problem with 3 letter codes is, that there are conflicts. EST means Eastern Standard Time, but it might be in America or Australia.

查看更多
在下西门庆
5楼-- · 2019-07-03 02:46

Time zones or daylight savings time start/end dates of cities might change (it did occur in the past) but the cities are likely to remain at the same location.

查看更多
爱情/是我丢掉的垃圾
6楼-- · 2019-07-03 02:51

http://us2.php.net/date_default_timezone_set

Quote from page: Note: Since PHP 5.1.0 (when the date/time functions were rewritten), every call to a date/time function will generate a E_NOTICE if the timezone isn't valid, and/or a E_STRICT message if using the system settings or the TZ environment variable.

查看更多
我命由我不由天
7楼-- · 2019-07-03 02:55

This is just a different timezone format provided by the Zoneinfo database:

The time zones in the database are given uniform names, such as “America/New_York”, in an attempt to make them easier to understand by humans and to remove ambiguity.

查看更多
登录 后发表回答