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