This article mainly introduces the sharing of user-defined functions for converting the U.S. time to Beijing time in php, providing the 13-hour and 8-hour algorithm versions respectively. For more information, see
This article mainly introduces the sharing of user-defined functions for converting the U.S. time to Beijing time in php, providing the 13-hour and 8-hour algorithm versions respectively. For more information, see
Since the email system recently used time conversion, it was necessary to convert the time for downloading emails from Google gmail to Beijing time, so I wrote a time conversion function, we hope to enlighten all those who need it. We all know that the time difference between China and the US is 13 hours. The following code is directly used:
Function datezhuanhuan ($ dateparams) {$ ccc = strtotime ($ dateparams); $ date = date ('Y-m-d '); $ bjtime = date ('Y-m-d', $ ccc); if ($ date = $ bjtime) {$ sbjtime = date ('Y-m-d H: i: s', $ ccc); echo substr ($ sbjtime, 11, 5);} else {$ sbjtime = date ('Y-m-d H: I: s ', $ ccc); return substr ($ sbjtime, 5, 5 );}}
Another 8-hour algorithm:
$ Bj_time = date ("Y-m-d H: I: s", mktime (gmdate ('H') + 8, gmdate ('I '), gmdate ('s'), gmdate ('M'), gmdate ('D'), gmdate ('y ')));