php时区转换转换函数
程序员文章站
2023-11-16 23:03:34
复制代码 代码如下:/* * 时区转换 */function totimezone($src, $from_tz = 'america/denver',...
复制代码 代码如下:
/*
* 时区转换
*/
function totimezone($src, $from_tz = 'america/denver', $to_tz = 'asia/shanghai', $fm = 'y-m-d h:i:s') {
$datetime = new datetime($src, new datetimezone($from_tz));
$datetime->settimezone(new datetimezone($to_tz));
return $datetime->format($fm);
}