A custom function sharing _php instance in PHP that converted American time to Beijing time

Source: Internet
Author: User
Tags american time

As a result of the recent mail system to use the time conversion, the need to download the mail from Google Gmail time into Beijing time, and then wrote a time conversion function, I hope to have the need for all the inspiration, we know the time difference between China and America 13 hours, the following directly on the code:

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 '));

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.