设置碳日期的时区格式 [英] Format Timezone for Carbon Date
本文介绍了设置碳日期的时区格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试为Carbon
对象中的日期设置时区.它在本地运行良好,但在我的生产机器上,它一直给我Bad timezone
错误.
I'm trying to set the timezone for a date in a Carbon
object. It works fine locally but on my production box it keeps giving me Bad timezone
error.
我尝试过:
$date->setTimezone('7');
$date->setTimezone('+7');
$date->setTimezone('7:00');
$date->setTimezone('+7:00');
$date->setTimezone('UTC 7');
$date->setTimezone('UTC +7');
$date->setTimezone('UTC 7:00');
$date->setTimezone('UTC +7:00');
不知道为什么它在我的生产包装箱上抱怨.也找不到有关在此处输入正确"格式的文档.有人可以帮忙吗.
No idea why it's complaining on my production box. Can't find documentation either on what is the "proper" format to enter here. Can someone please help.
仅供参考:local是Windows,prod是Ubuntu box.
FYI: local is windows, and prod is Ubuntu box.
推荐答案
您可以通过以下方式更改时区:
You can change the timezone with this:
$timestamp = '2014-02-06 16:34:00';
$date = Carbon::createFromFormat('Y-m-d H:i:s', $timestamp, 'Europe/Stockholm');
$date->setTimezone('UTC');
这种格式对我的Local(Ubuntu)和prod(Redhat)项目都适用.
this format working fine to my Local(Ubuntu) and prod(Redhat) project.
这篇关于设置碳日期的时区格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文