问题标签 [timestamp-with-timezone]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
1659 浏览

mysql - STR_TO_DATE 和 ISO8601 Atomtime 格式

我有一个我无法更改的 MySQL 数据库,我从中读取日期。问题是我有一个存储日期的 varchar 列。日期以 atomtime 格式存储,例如。2014-06-01T00:00:00+02:00.

我不知道如何在 STR_TO_DATE 函数中指定格式。我试过STR_TO_DATE(Endtime, '%Y-%m-%dT%H:%i:%s+02:00')了,但这不起作用。

有人对此有解决方案吗?

我正在尝试运行以下查询(无法正常工作):

提前致谢。

0 投票
1 回答
139 浏览

javascript - 如何更改具有不同时区的javascript中的日期

我将日期保存在 unix-timestamp 中的数据库中。我已将时区默认设置为:

但在 javascript 中,我通过以下方式更改时间戳:

上面的代码改变了时间,但它不在我提到的时区。

0 投票
2 回答
331 浏览

sql - 尝试使用夏令时时出现 ORA-1882

我们收到来自外部提供商的文件。其中一列包含格式为“05/01/2014 09:25:41 AM EDT”的时间戳。我正在尝试使用以下 SQL 将其插入到 TIMESTAMP WITH TIME ZONE 列中:

INSERT INTO table VALUES (to_timestamp_tz('05/01/2014 09:25:41 AM EDT', 'MM/DD/YYYY HH12:MI:SS AM TZR TZD'));

那是我得到的时候ORA-1882: timezone region not found。我也试过这样指定

INSERT INTO table VALUES (to_timestamp_tz('05/01/2014 09:25:41 AM EST EDT', 'MM/DD/YYYY HH12:MI:SS AM TZR TZD'));

但后来我明白了ORA-1857: not a valid time zone

有人知道我如何插入这个吗?我们正在运行 Oracle 11.2.0.3。我可以看到,v$timezone_names对于 tzname 'America/New York',EST 和 EDT 似乎都是有效的 tzabbrev。

编辑:

看来,如果我用 EST5EDT 代替 EDT(以及 CST6CDT、MST7MDT 和 PST8PDT 分别代替 CST、MST 和 PST),我可以获得我需要的行为。这样做的问题是我需要提前知道这些替换是什么,以便我可以围绕它们进行编码。我仍然需要知道如何处理其他时区的潜在夏令时问题。

0 投票
3 回答
1176 浏览

php - Finding midnight of a timezone given offset in minutes [PHP]

I have an offset from UTC stored in minutes: e.g -240

I'm trying to find the corresponding UNIX timestamp of midnight of the current day for this particular offset.

I found similar information in questions like this one: How do I get the UTC time of "midnight" for a given timezone?

However, I don't have the city name/timezone jurisdiction, just a minute offset. I think this should be fine since for my purposes I don't need to account for daylight savings, it can be off by an hour and still be fine.

Examples

Offset: -420

Midnight on 7/12/2014: 1405148400 (unix TS)

With UTC, I would have to first tell if it's the next day or same day as the TZ because it may have a different "last midnight".

0 投票
1 回答
1266 浏览

java - 是否可以在没有格式解析的情况下将字符串转换为日期或时间戳

  • 在这里我不想使用简单的格式将字符串转换为日期或时间戳,
  • 如果上面的代码运行我会得到异常,illegalArgumentException

    时间戳格式必须为 yyyy-mm-dd hh:mm:ss[.fffffffff]**

  • 是否可以使用 out 格式转换字符串日期。
  • 如果可能的话对我很有帮助。

0 投票
0 回答
83 浏览

python - 从 Python 中的 pandas DateTimeIndex 中丢失时区感知

我在熊猫 0.13.1 上。假设我需要使用时区通过分层索引中的两个时间戳来索引数据,这种方法可以正常工作:

我得到:

尽管

返回时区朴素索引:

期望两者返回相同的时区。这是预期的吗?

0 投票
1 回答
436 浏览

python - 在 Python 中将分层熊猫 DatetimeIndex 保存到 hdf5 时失去时区意识

我在熊猫 0.14.1 上。假设我需要使用时区按分层索引中的两个时间戳对数据进行索引。将结果 DataFrame 保存到 hdf5 时,我似乎失去了时区意识:

这里df有时区:

保存并加载到 hdf5 后,时区信息似乎消失了:

结果是:

我想知道是否有一个好的解决方法,以及这是否是一个已知的错误。

0 投票
0 回答
944 浏览

python - 在 Python 中连接 DataFrame 时更改 pandas DatetimeIndex 的时区

我在熊猫 0.14.1 上。有两个 DataFrames 都由时区感知 DatetimeIndex 索引:

两个索引都有时区,一个有频率,一个没有:

然后将两个更改时区连接到UTC

我想知道这是一个已知的错误还是有特定的原因。

0 投票
3 回答
2007 浏览

java - C# DateTime in Java

I am trying to convert millseconds to time in Java.

when I do this in C#

result 24/07/2014 12:33:05

when I do same in Java

result Thu Jul 24 13:33:05 BST 2014

The Java result add 1 more hour than C# .

Any suggestion how can I fix this?

0 投票
1 回答
102 浏览

php - 在 MySQL 的其他列中转换和存储日期和时间

我在 MYSQL 中有 ID 为 Req_Order_No(Varchar) 、 Req_In_Time(DateTime) 、 Req_Out_Time(DateTime) 的数据库

示例行如下所示:

上述日期和时间为 EST 格式。我想将它们都转换并以 IST 格式存储在其他列中

我试过了SELECT CONVERT_TZ('Req_In_Time','-05:00','+9:30');

但它返回 NULL 值。

请帮忙。我还需要php吗?