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 about how to convert the time used in the recent email system, you need to convert the email download time from Google gmail to Beijing time. Therefore, you have written 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 ')));