简体   繁体   English

如何在PHP中将UTC + 6转换为本地时间

[英]How to turn UTC+6 into local time in PHP

i have a table with several timezones but just saved as string like "UTC+1" or "UTC-6" etc 我有一个带有多个时区的表,但只是另存为“ UTC + 1”或“ UTC-6”等字符串

how do i put that through the DateTime function to get what the time would be now in that zone 我该如何通过DateTime函数来获取该区域现在的时间

is it even possible? 可能吗?

am i close with this?: 我是否与此紧密?:

$localtime = new DateTime("now", "UTC+6");

thanks 谢谢

I've never tried this trick, but looks like this question is already been asked and answered: 我从来没有尝试过这个技巧,但是看起来这个问题已经被提出并得到了回答:

php: setting a timezone by UTC offset PHP:通过UTC偏移量设置时区

您应该像这样使用date_default_timezone_set

date_default_timezone_set(UTC+6 TIMZONE HERE);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM