此代码工作不正常,使用计算机中的时区返回时间,忽略WordPress选项中存储的时区:
date_default_timezone_set( get_option( \'timezone_string\' ) );
$hours = date( \'H\', strtotime( $timestamp ) );
date_default_timezone_set(@date_default_timezone_get());
WordPress在选项部分保存时区,但wp\\U选项表中的“timezone\\u string”选项为空。代码还会生成警告。How to get date using timezone saved in options correctly?
Where does WordPress store an Timezone which can be edited in options section?