Home >Backend Development >PHP Tutorial >PHP custom function to convert American time to Beijing time

PHP custom function to convert American time to Beijing time

WBOY
WBOYOriginal
2016-07-25 08:53:001259browse
  1. function datezhuanhuan($dateparams)
  2. {
  3. $ccc=strtotime($dateparams);
  4. $date=date('Y-m-d');
  5. $bjtime=date('Y-m-d',$ccc );
  6. if($date==$bjtime)
  7. {
  8. $sbjtime=date('Y-m-d H:i:s',$ccc);
  9. echo substr($sbjtime,11,5);
  10. } // bbs .it-home.org
  11. else
  12. {
  13. $sbjtime=date('Y-m-d H:i:s',$ccc);
  14. return substr($sbjtime,5,5);
  15. }
  16. }
Copy code

Attached, another +8 hour algorithm:

  1. $bj_time = date ("Y-m-d H:i:s" , mktime(gmdate('H')+8,gmdate('i'),gmdate('s'),gmdate('m' ),gmdate('d'),gmdate('Y')));
Copy code


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn