PHP Get server time (solve 8-hour gap problem) below these three to get the current time is very good to solve the 8-hour gap problem, as long as the acquisition time before adding Date_default_timezone_set (\ "asia/chongqing\"); When we solve the time zone problem, we usually use the date (), which will have jet lag problem.
PHP Tutorial Get server time (solve 8-hour gap problem)
The following three to get the current time is a good solution to the 8-hour gap problem, as long as the acquisition time before adding Date_default_timezone_set ("asia/chongqing"); Solve the time zone problem, we usually use date () The function has a time difference problem.
/**
* Get Server Current date time
*/
function Get_server_datetime ()
{
Date_default_timezone_set ("asia/chongqing");
Return Date ("y-m-d h:i:s");
}
/**
* Get Server Current date
*/
function Get_server_date ()
{
Date_default_timezone_set ("asia/chongqing");
Return date ("Ymd");
}
/**
* Gets the current time of the server
*/
function Get_time ()
{
Date_default_timezone_set ("asia/chongqing");
$timeval ["h"] = Date ("H"); Hours
$timeval ["i"] = date ("I"); Minutes
$timeval ["s"] = date ("s"); Seconds
return $timeval;
}
http://www.bkjia.com/PHPjc/632366.html www.bkjia.com true http://www.bkjia.com/PHPjc/632366.html techarticle PHP Get server time (solve the 8-hour gap problem) below these three to get the current time is very good to solve the 8-hour gap problem, as long as the acquisition time before adding date_default_timezone_ ...