【发布时间】:2017-03-03 10:50:08
【问题描述】:
我们将欧洲/马德里时间的日期作为日期时间存储在我们的 MySQL 表中,在 PHP 中我们称之为 $h
$h 的格式是 2017-03-03 17:30:00
我想知道是否有一种简单的方法可以将这个时间($h)转换为另一个时区
类似
$h1=changetimezone ($h, 'Europe/Madrid', 'Europe/Dublin')
其中 h1 是 h-1 小时
这个例子的结果是 2017-03-03 16:30:00
谢谢
编辑
我试过了
$h1 = new DateTime($h, new DateTimeZone('Europe/Madrid'));
$h1->setTimeZone(new DateTimeZone('Europe/Dublin'));
但我有
$f=strftime('%e/%m/%y %H:%M', strtotime($h1));
我明白了
strtotime() expects parameter 1 to be string, object given
编辑 2:
原始 $h vardump:
string(19) "2017-03-03 17:30:00"
但它在 MySQL 中存储为日期时间
【问题讨论】: