使用 javascript 我知道我的用户时区是 UTC +3.
Using javascript I know that my users timezone is UTC +3.
现在我想用这些知识创建 DateTime 对象:
Now I want to create DateTime object with this knowledge:
$usersNow = new DateTime('now', new DateTimeZone("+3"));
我收到了回复:
'Unknown or bad timezone (+2)'
我做错了什么?我该如何解决?
What am I doing wrong? How can I fix?
这个怎么样...
$original = new DateTime("now", new DateTimeZone('UTC'));
$timezoneName = timezone_name_from_abbr("", 3*3600, false);
$modified = $original->setTimezone(new DateTimezone($timezoneName));
这篇关于php:通过 UTC 偏移量设置时区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!