Firebase.ServerValue.TIMESTAMP的时区

时间:2021-10-17 15:23:11

It appears that when I use Firebase.ServerValue.TIMESTAMP currently, it is using PDT (I assume that will be changing to PST in the fall).

当我使用Firebase.ServerValue.TIMESTAMP时,它似乎正在使用PDT(我假设将在秋季更改为PST)。

Is there a way to get this in UTC instead of PDT?

有没有办法在UTC而不是PDT中获取此信息?

1 个解决方案

#1


28  

Firebase timestamps are always stored as milliseconds since the epoch (midnight of 1/1/1970 in UTC). This is the same way that dates work in Javascript and many other languages. This is a timezone-agnostic way of representing time.

自从纪元(1970年1月1日午夜以UTC为单位)以来,Firebase时间戳始终存储为毫秒。这与日期在Javascript和许多其他语言中的工作方式相同。这是一种表示时间的时区无关的方式。

Generally speaking, timezone only plays a role in how a time is displayed to a user, not in how it's represented under-the-hood. Firebase timestamps are no different.

一般来说,时区只在如何向用户显示时间方面发挥作用,而不是在如何在引擎盖下显示时间。 Firebase时间戳也不例外。

So, if you construct a JS date object using a timestamp created by Firebase.ServerValue.TIMESTAMP, it will automatically have the same timezone as the machine on which it is being displayed.

因此,如果使用Firebase.ServerValue.TIMESTAMP创建的时间戳构造JS日期对象,它将自动具有与显示它的机器相同的时区。

#1


28  

Firebase timestamps are always stored as milliseconds since the epoch (midnight of 1/1/1970 in UTC). This is the same way that dates work in Javascript and many other languages. This is a timezone-agnostic way of representing time.

自从纪元(1970年1月1日午夜以UTC为单位)以来,Firebase时间戳始终存储为毫秒。这与日期在Javascript和许多其他语言中的工作方式相同。这是一种表示时间的时区无关的方式。

Generally speaking, timezone only plays a role in how a time is displayed to a user, not in how it's represented under-the-hood. Firebase timestamps are no different.

一般来说,时区只在如何向用户显示时间方面发挥作用,而不是在如何在引擎盖下显示时间。 Firebase时间戳也不例外。

So, if you construct a JS date object using a timestamp created by Firebase.ServerValue.TIMESTAMP, it will automatically have the same timezone as the machine on which it is being displayed.

因此,如果使用Firebase.ServerValue.TIMESTAMP创建的时间戳构造JS日期对象,它将自动具有与显示它的机器相同的时区。