How to calculate the date and time difference-

Source: Internet
Author: User
The calculation method of date plus time difference--URGENT!!!!!

Date_default_timezone_set (' etc/gmt ');
$now = mktime (Date (' H '), date (' I '), date (' s '), date (' m '), date (' d '), date (' Y ')) + $timezone *60*60*1000;
$site _date = Date ("G:i A (D)", $now);


Where timezone is the time difference. Why do I use this, to get the wrong time ah.

Please help the master to solve.


------Solution--------------------
$t = time ();
echo Date (' Beijing time y-m-d h:i:s ', $t), '
';
Date_default_timezone_set (' etc/gmt ');
echo date (' GMT y-m-d h:i:s ', $t), '
';

for ($i =1; $i <=12; $i + +) {
Date_default_timezone_set ("etc/gmt-$i");
echo Date ("East $i time y-m-d h:i:s", $t), '
';
}
Beijing Time 2013-01-09 14:14:01
GMT 2013-01-09 06:14:01
East 1 time 2013-01-09 07:14:01
East 2 Time 2013-01-09 08:14:01
East 3 Time 2013-01-09 09:14:01
East 4 Time 2013-01-09 10:14:01
East 5 Time 2013-01-09 11:14:01
East 6 Time 2013-01-09 12:14:01
East 7 Time 2013-01-09 13:14:01
East 8 Time 2013-01-09 14:14:01
East 9 Time 2013-01-09 15:14:01
East 10 Time 2013-01-09 16:14:01
East 11 Time 2013-01-09 17:14:01
East 12 Time 2013-01-09 18:14:01

------Solution--------------------
References:
Reference: Usage:
Echo fun::now (' y-m-d h:i:s ', Time ());//2012-10-30 00:13:40
Echo fun::now (' y-m-d h:i:s ');//2012-10-30 00:13:40
Echo Fun::now ();//1351527292
Echo time ();//135152729
...
Because I put this new into the fun of this class, you can use it to echo now (' y-m-d h:i:s ', Time ()),//2012-10-30 00:13:40
  • Related Article

    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.