php UTC 和 Etc/UTC 时区之间有区别吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14128574/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is there a difference between the UTC and Etc/UTC time zones?
提问by Benjamin
In the PHP documentation, list of supported time zones, UTCis listed twice:
在PHP文件,支持的时区列表,UTC列出了两次:
UTCEtc/UTC
UTCEtc/UTC
Is there any conceptual difference between those two, or are they just synonyms?
这两者在概念上有什么区别,还是只是同义词?
采纳答案by David Schwartz
Etc/UTCis the specified for the time zone whose display name is UTC. That is, they're long and short names for the same timezone, per IANA's time zone database.
Etc/UTC是为显示名称为 的时区指定的UTC。也就是说,根据IANA 的时区数据库,它们是同一时区的长名称和短名称。
回答by Andreas Rayo Kniep
Firstly, to answer the question:
There is NO difference between UTCand Etc/UTCtime zones.
首先,回答这个问题:和时区
之间没有区别。UTCEtc/UTC
Etc/UTCis a timezone in the Olson-timezone-database (tz database), also known as IANA-timezones-database, in which all timezones conform to a uniform naming convention: Area/Location.
Etc/UTC是 Olson-timezone-database ( tz database)中的一个时区,也称为IANA-timezones-database,其中所有时区都遵循统一的命名约定:Area/Location.
Since, some timezones cannot be attributed to any Area of the world (i.e. continents or oceans), the special Area Etc(Etcetera) was introduced. This applies mainly to administrative timezones such as UTC.
Thus, to conform with the naming convention, the universal coordinated time(zone) is named Etc/UTCin the tz database.
由于某些时区不能归属于世界上的任何区域(即大陆或海洋),因此引入了特殊区域Etc(Etcetera)。这主要适用于行政时区,例如UTC.
因此,为了符合命名约定,Etc/UTC在 tz 数据库中命名了通用协调时区。
For administrative timezones other than UTC (e.g. GMT+4, GMT-8), the tz database uses POSIX-style signsin the zone-names. POSIX has positive signs for zones that are behind Greenwich (west of Greenwich) and negative signs for zones that are ahead of Greenwich (east of Greenwich).
对于 UTC 以外的管理时区(例如GMT+4, GMT-8),tz 数据库在区域名称中使用POSIX 样式的标志。POSIX 对格林威治(格林威治以西)后面的区域有正号,对格林威治之前(格林威治以东)的区域有负号。
POSIX-style signs in timezones are the opposite of the definition of timezones in the nowadays widespread and mostly used ISO 8601. In the ISO 8601 timezone format, negative signs indicate a zone is behind UTC (west of Greenwich) and positive signs indicate a zone is ahead of UTC (east of Greenwich). This is what has become the standard usage nowadays.
时区中的 POSIX 样式标志与当今广泛使用且主要使用的ISO 8601 中的时区定义相反。在 ISO 8601 时区格式中,负号表示区域落后于 UTC(格林威治以西),正号表示区域领先于 UTC(格林威治以东)。这已成为当今的标准用法。
Possible reasons for the opposite definition in POSIX are:
POSIX 中相反定义的可能原因是:
- POSIX is part of UNIX, which was developed in the USA, which is behind UTC (west of Greenwich). The POSIX format allows the US timezones to be represented as EST5, PST8, i.e. omitting the (+) sign.
- Usually, computer programs and operating systems internally do everything in UTC time. With POSIX-style signs you can add time and timezone in order to get UTC time. Example: "03:30 PST8" or "03:30 GMT+8" mean it is "11:30 UTC".
- POSIX 是 UNIX 的一部分,UNIX 是在美国开发的,它落后于 UTC(格林威治以西)。POSIX 格式允许将美国时区表示为 EST5、PST8,即省略 (+) 符号。
- 通常,计算机程序和操作系统在内部以 UTC 时间执行所有操作。使用 POSIX 风格的标志,您可以添加时间和时区以获得 UTC 时间。例如:“03:30 PST8”或“03:30 GMT+8”表示它是“11:30 UTC”。
回答by arganzheng
ETC/GMT+4 is the same as GMT-4.
ETC/GMT+4 与 GMT-4 相同。
public static void main(String[] args) {
TimeZone tz = TimeZone.getTimeZone("Etc/GMT-7");
System.out.println(tz);
tz = TimeZone.getTimeZone("GMT+7");
System.out.println(tz);
}
You can test it by yourself.
你可以自己测试一下。
But I don't know what ETC mean..
但是我不知道ETC是什么意思..

