PHP 按照时区获取当前时间


/**
  * 时间格式化
  * @param string $dateformat 时间格式
  * @param int $timestamp 时间戳
  * @param int $timeoffset 时区偏差
  * @return string
  */
function qgmdate( $dateformat = 'Y-m-d H:i:s' , $timestamp = '' , $timeoffset = 8) {
 
     if ( empty ( $timestamp )) {
         $timestamp = time();
     }
     $result = gmdate ( $dateformat , $timestamp + $timeoffset * 3600);
     return $result ;
}
//-4是美国时间,8是默认的北京时间
qgmdate( 'Y-m-d H:i:s' , '' , -4);


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM