【发布时间】:2018-04-25 12:32:31
【问题描述】:
我正在实施一个注册工具,它发送一个带有令牌的链接 - 该令牌的有效期为 1 小时。所以在邮件中(假设现在是 14:20)我想说:
您必须在 15:30 之前点击此链接
该网站的受众将来自爱尔兰/英国、美国/加拿大,也许还有一些欧洲 - 所以我想列出这些(非技术人员)可以理解的几个时区的到期时间。
这就是我的想法
Click by:
Ireland/UK > 25 Apr 2018 13:59
CET (Berlin) > 25 Apr 2018 14:59
Pacific (Los Angeles) > 25 Apr 2018 05:59
Mountain (Denver) > 25 Apr 2018 06:59
Central (Chicago) > 25 Apr 2018 07:59
Eastern (New York) > 25 Apr 2018 08:59
现在,我知道丹佛目前是 MDT(冬季是 MST),但在爱尔兰,我们现在在冬季/秋季处于 IST(UTC + 1)或 GMT - 但如果你随便问一个人我们在哪个时区,充其量您全年都会收到 GMT 作为响应。因此,我将那里的时间列为通用“山”,并给出了一个示例城市。
这种方法对美国/加拿大的人来说如何?
我的代码如下,这里是live link
<?php
$exipry = 60*60 + time();
$now_obj = new DateTime(date("Y-m-d H:i:s", $exipry));
$now_obj->setTimezone(new DateTimeZone('Europe/Dublin'));
$now_hour_from_IRELAND_datetime = $now_obj->format('d M Y H:i');
$now_obj->setTimezone(new DateTimeZone('Europe/Berlin'));
$now_hour_from_CET_datetime = $now_obj->format('d M Y H:i');
$now_obj->setTimezone(new DateTimeZone('America/Los_Angeles'));
$now_hour_from_pacific_datetime = $now_obj->format('d M Y H:i');
$now_obj->setTimezone(new DateTimeZone('America/Denver'));
$now_hour_from_mountain_datetime = $now_obj->format('d M Y H:i');
$now_obj->setTimezone(new DateTimeZone('America/Chicago'));
$now_hour_from_central_datetime = $now_obj->format('d M Y H:i');
$now_obj->setTimezone(new DateTimeZone('America/New_York'));
$now_hour_from_eastern_datetime = $now_obj->format('d M Y H:i');
print("<h1>1 hour from now is:</h1>");
print("Ireland/UK > $now_hour_from_IRELAND_datetime<p>");
print("CET (Berlin) > $now_hour_from_CET_datetime<p>");
print("Pacific (Los Angeles) > $now_hour_from_pacific_datetime<p>");
print("Mountain (Denver) > $now_hour_from_mountain_datetime<p>");
print("Central (Chicago) > $now_hour_from_central_datetime<p>");
print("Eastern (New York) > $now_hour_from_eastern_datetime<p>");
?>
【问题讨论】:
-
谢谢。但我对 UI 方面更感兴趣,比如北美人对时区的熟悉程度以及我的文字是否清晰?
-
您能否澄清您的问题:您是否只是想知道您的列表中应包含哪些时区以涵盖美国和加拿大?或者你也想要其他人?请具体。谢谢。
-
在 O Jones 的回答下方查看我的评论 - 美国客户需要这个,更有可能在东海岸。尝试以尽可能简单的语言呈现链接到期时间,而不会使事情复杂化,尽可能说 DST
标签: datetime user-interface time timezone