PHP Get server time (solve 8-hour gap problem) _php Tutorial

Source: Internet
Author: User
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_ ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.