【发布时间】:2021-09-25 11:45:05
【问题描述】:
无论客户的时区如何,我都想知道特定 PST 时间的下一次出现有多远。
如果时间是 UTC,这将是微不足道的,但我不知道如何在 PST 中做到这一点,记住要遵守夏令时。
例如。太平洋标准时间下午 4 点将是世界标准时间晚上 11 点,因为现在是夏天。
我宁愿不必手动输入夏令时的日期。
如果没有库就无法使用,我很乐意使用。
// returns the number of milliseconds from the current time until the specified time in PST.
function getTimeUntil (hour, minutes = 0, seconds = 0)
{
// implementation needed
}
【问题讨论】:
-
假设 PST 是美国太平洋标准时间,那么太平洋标准时间下午 4 点 (16:00) 始终是 00:00 UTC,因为 PST 有一个固定的偏移量:UTC -8。大多数(尽管不是全部)在冬季观察 PST 的地方在夏季观察 PDT(UTC -7)。在那些地方 16:00 PDT 是 23:00 UTC。
标签: javascript date timezone dst