我写了第一个wordpress插件,它查看服务器上的文件并返回时间戳。我的问题是,服务器的时间戳是上午8点,但返回值是13:00。如何在PHP中调整时间戳以匹配实时?以下是我使用的代码:在PHP中设置正确的时区日期函数
function wp_file_last_updated($atts){
$a = shortcode_atts (array(
'url' => 'No File Specified'
), $atts);
$filename = $a['url'];
if (file_exists($filename)) {
return "$filename was last modified: " . date ("F d Y H:i:s.", filemtime($filename));
}
}
add_shortcode('filedate', 'wp_file_last_updated');
?>
WordPress的时区并没有帮助上市,但添加在PHP函数做的伎俩!感谢您的帮助。 – Craig