- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
希望有人注意到我遇到的问题的原因。
对于所有其他时区,例如“欧洲/赫尔辛基”,下面的偏移量计算返回正确的值,但出于某种原因,我得到“Etc/GMT+2”样式时区的负值,反之亦然(例如,对于 Etc/GMT- 2 我得到正值,7200)。
$dateTimeZone = new DateTimeZone('Etc/GMT+2');
echo $dateTimeZone->getOffset(new DateTime("now", new DateTimezone( 'UTC' )));
预期:7200结果:-7200
最佳答案
Etc/GMT+2
时区否则将被称为“GMT -2”或表示为 <date time>-02:00
.
这是由于 POSIX 表示这些类型的时区偏移的方式:
The offset specifies the time value you must add to the local time to get a Coordinated Universal Time value. It has syntax like [+|-]hh[:mm[:ss]]. This is positive if the local time zone is west of the Prime Meridian and negative if it is east. The hour must be between 0 and 23, and the minute and seconds between 0 and 59.
From TZ Variable.
和:
Numeric time zone abbreviations typically count hours east of UTC, e.g., +09 for Japan and -10 for Hawaii. However, the POSIX TZ environment variable uses the opposite convention. For example, one might use TZ="JST-9" and TZ="HST10" for Japan and Hawaii, respectively. If the tz database is available, it is usually better to use settings like TZ="Asia/Tokyo" and TZ="Pacific/Honolulu" instead, as this should avoid confusion, handle old time stamps better, and insulate you better from any future changes to the rules. One should never set POSIX TZ to a value like "GMT-9", though, since this would falsely claim that local time is nine hours ahead of UTC and the time zone is called "GMT".
From Sources for Time Zone and Daylight Saving Time Data - Time notation.
关于php DateTimeZone->getOffset() 返回 GMT 时区的无效偏移量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5339547/
在 /usr/share/lib/zoneinfo 下 我可以看到以下 4 种不同类型的 GMT 信息 GMT GMT+0 GMT-0 GMT0 这 4 种 GMT 区域时间之间有什么区别吗?如果是这
我有这样的输入格式,我需要将其转换为 GMT 格式: $input = array( "gmt" => "+7", "datetime" => "2017-
我尝试了以下代码,应该允许我将时间传递作为参数转换为一个多一小时 (GMT+1) 的字符串。 但我总是得到与我对象时间相同的时间 public static String getFormattedTi
为什么 GMT-0400 在 1989 年之前转变为 GMT-0500? > new Date('1989-04-02T23:01:14.52Z') Sun Apr 02 1989 19:01:14
我从服务器获取日期字符串及其 GMT+2 我认为无法转换为印度 GMT 5:30 格式 这是服务器日期字符串 2017-01-11T05:08:15.157Z 我想要印度时间格式的这个我已经尝试了下面
我每分钟运行一个任务,我想打印出当前 GMT 时间和 9PM GMT 之间的差异,我希望它一直运行,所以一旦到达 9PM GMT,它就会重置为 24 小时所以它正在寻找第二天晚上 9 点(格林威治标准
在这方面遇到了困难,尝试了所有这些不同的日期函数,但不知道如何确定地做到这一点。 最佳答案 您可以使用calendar.timegm来获取自纪元以来的秒数。时间元组是必需的参数,time.strpti
我知道有多种方法可以将日期时间转换为 Unix 时间戳。 但问题是当我们将 GMT 的日期时间值转换为 Unix 时间戳时,它会根据我本地时区的值显示时间戳的值,即 Asia/Kolkata 例如:G
当我将 user_login_date 存储到数据库中时,它是 GMT +5:30,但我的数据库设置为 GMT 0:00 用户在 12:00:00 登录但数据库将该日期存储为 07:30:00 的示例
当我使用“日期”命令时,我们的服务器提供 GMT 时间。但是我现在的时间应该是GMT+8。如何将当前时间显示为 GMT+8?提前致谢。 最佳答案 将这样的一行添加到您的 .profile 文件中,然后
我正在使用此代码获取 android 设备的 timezone TimeZone tz = TimeZone.getDefault(); String current_Time_Zone = (Tim
我也想要 GMT 字符串的时间。 但我无法得到它。 DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd/hh-mm"); dateForm
我也是 MVC3 和 C# 的新手。我将使用 C# 通过 MVC3 创建一个测试博客站点。用户可以在哪里写帖子,所以我需要存储用户帖子日期时间,并想在自己的本地时间显示每个其他用户的日期时间。对于这种
我在使用 PHP DateTime 将 GMT -8 时区 (PST) 接收的日期转换为 GMT -7 (PDT) 时区的人类可读格式时遇到困难。 这是一个例子: $tz = new DateTime
例如,我想解析下面的字符串: Tue Sep 28 18:02:24 GMT+08:00 2010 我使用 SimpleDateFormat 的模式: new SimpleDateFormat("EE
我正在尝试使用 html 输入中的信息查询数据库。日期的格式为: Date {Sun Jun 03 2012 00:00:00 GMT+0100 (GMT Daylight Time)} 在我
我有一种情况,我收到以下格式的字符串形式的日期。 “2014 年 1 月 13 日星期一 00:00:00 GMT+0000(GMT 标准时间)” 我需要在 c# 中将其转换为以下格式(日期/字符串)
我能够从完整的字符串名称“Australia/Brisbane”中获取 Java 中的时区对象 TimeZone tz = TimeZone.getTimeZone("Australia/Brisba
我能够从完整的字符串名称“Australia/Brisbane”中获取 Java 中的时区对象 TimeZone tz = TimeZone.getTimeZone("Australia/Brisba
我有这些数据可供使用: Timezone of local time as integer: 8.75 (which is UTC+8.75) 1) 2012-09-04 03:15:03 2) 20
我是一名优秀的程序员,十分优秀!