所以我有以下
- 有时间和时区的比赛,这可能与每场比赛不同
- 具有时区的用户
现在我想要什么?
我想在他的时区显示用户的时间,所以如果比赛是在 GMT+0(欧洲/伦敦)的 12:00,那么我希望它显示为欧洲/阿姆斯特丹的 13:00。
我不知道该怎么做,请帮帮我;)
编辑对不起,我使用 PHP
您可以使用 PHP 的DateTime类,它在处理日期/时间和时区方面做得非常出色。这是您想要的示例。
/* Create a DateTime object using Europe/London Timezone */
$date = new DateTime("2012-12-10 12:00", new DateTimeZone("Europe/London"));
echo $date->format('r'); // Mon, 10 Dec 2012 12:00:00 +0000
/* Change the timezone to Europe/Amsterdam and output the new formatted date/time */
$date->setTimezone(new DateTimeZone("Europe/Amsterdam"));
echo $date->format('r'); // Mon, 10 Dec 2012 13:00:00 +0100