是否有任何php函数可以将日期字符串转换为其等效的亚洲/马尼拉时间。我尝试将亚洲马尼拉设置为我的默认时区,但无济于事。请参阅下面的示例,需要转换为亚洲/马尼拉时间
Sun, 12 Jan 2015 08:27:42 +0000,
Mon, 12 Jan 2015 00:14:04 -0500,
Mon, 12 Jan 2015 05:13:34 +0000 (UTC),
Mon, 12 Jan 2015 08:57:47 +0000 (UTC),
Tue, 13 Jan 2015 01:38:04 +0700 (WIT),
Tue, 13 Jan 2015 00:47:31 +0900 (JST),
Mon, 12 Jan 2015 23:27:26 +0000
非常感谢您的帮助。提前谢谢。
这是最简单的方法
date_default_timezone_set('Asia/Manila'); // Set your default TZ to Asia/Manila
// strtotime() will convert all timezones to your default
echo date('Y-m-d H:i:s' , strtotime('Mon, 12 Jan 2015 05:13:34 +0000 (UTC)'));
试试这个
$date = new DateTime('2000-01-01', new DateTimeZone('Asia/Manila'));
echo $date->format('Y-m-d H:i:sP') . "n";
请尝试以下操作
$sdt = '2012-05-15 10:50:00';
$stz = new DateTimeZone('UTC');
$dtz = new DateTimeZone('Asia/Manila');
$dt = new DateTime($sdt, $stz);
$dt->setTimeZone($dtz);
$ddt = $dt->format('Y-m-d H:i:s');
希望这对你有帮助。
函数convert_timezone($from_tz, $to_tz, $time = '2008-08-03 12:35:23') {
date_default_timezone_set($from_tz);
$datetime = new DateTime($time);
$time_newTZ = new DateTimeZone($to_tz);
$datetime->setTimezone($time_newTZ);
$newDate = $datetime->format('Y-m-d H:i:s');
return $newDate;
}
回声convert_timezone("亚洲/Kuala_Lumpur"、"美洲/Los_Angeles");