Forum Moderators: coopster
This is an example:
$date = '2008-10-13';
$date = strtotime($date);
echo $date."-".date('Y-m-d H:i:s',$date)."<br>";
$date = $date + (-1 * 60*60*24);
echo $date."-".date('Y-m-d H:i:s',$date)."<br>";
Output:
1223863200-2008-10-13 00:00:00
1223776800-2008-10-11 23:00:00
It goes from 13 to 11?!
I've been testing with different values and it seems that it doesn't count from 2008-10-12 00:00:00 to 2008-10-12 01:00:00. Why does it happen?
Thanks in advance!
<?
$firstDate='2008-10-13';
$firstDateTS=strtotime($firstDate);
$secondDateTS=strtotime("$firstDate -1 day");
echo $firstDateTS."-".date('Y-m-d H:i:s',$firstDateTS)."<br>";
echo $secondDateTS."-".date('Y-m-d H:i:s',$secondDateTS)."<br>";
?>
Btw, TS=timestamp
[edited by: Anyango at 6:55 pm (utc) on Oct. 20, 2008]