This article mainly introduces the sharing of the Pacific time and custom functions implemented by php and the Beijing time, mainly based on the date_default_timezone_set function. For more information, see
This article mainly introduces the sharing of the Pacific time and custom functions implemented by php and the Beijing time, mainly based on the date_default_timezone_set function. For more information, see
There is nothing to say, just go to the Code:
/*** Pacific time to Beijing time */public function pacificToPRC ($ time = '') {date_default_timezone_set ('pacpacific/Apia '); if (empty ($ time )) {$ time = time ();} date_default_timezone_set ('Asia/Shanghai'); $ date = date ('Y-m-d H: I: s', $ time ); $ time = strtotime ($ date); return $ time ;} /*** Beijing time to Pacific time * @ param unknown_type $ time */public function PRCToPacific ($ time = '') {if (empty ($ time )) {date_default_timezone_set ('Asia/Shanghai'); $ time = time ();} date_default_timezone_set ('pacpacific/Apia '); $ date = date ('Y-m-d H: i: s', $ time); $ time = strtotime ($ date); return $ time ;}