On 10 Apr 2004 Brian Dunning wrote: > Check this out: I'm returning a list of the last 30 days, looping > through i, subtracting it from $end_date where $end_date is 2004-04-10 > 00:00:00. I'm just trying to derive a timestamp $check_date for each > iteration, like 1081321200. Here's the code within the loop: > > $check_date = mktime(0, 0, 0, substr($end_date, 5, 2), > substr($end_date, 8, 2) - $i, substr($end_date, 0, 4), -1); > > Note that this works PERFECTLY for every date, and always has. Except > for one particular day. When $end_date - $i is supposed to be April 4, > the timestamp returned is -7262, which it thinks is 12/31/1969.
I don't see the same problem. This code: <?php $end_date = "2004-04-10"; for ($i = 1; $i <= 30; $i++) { $check_date = mktime(0, 0, 0, substr($end_date, 5, 2), substr($end_date, 8, 2) - $i, substr($end_date, 0, 4), -1); $strdate = date("m-d-Y", $check_date); print("$check_date = $strdate\n"); } ?> Produces this output: 1081483200 = 04-09-2004 1081396800 = 04-08-2004 1081310400 = 04-07-2004 1081224000 = 04-06-2004 1081137600 = 04-05-2004 1081054800 = 04-04-2004 1080968400 = 04-03-2004 1080882000 = 04-02-2004 1080795600 = 04-01-2004 1080709200 = 03-31-2004 1080622800 = 03-30-2004 1080536400 = 03-29-2004 1080450000 = 03-28-2004 1080363600 = 03-27-2004 1080277200 = 03-26-2004 1080190800 = 03-25-2004 1080104400 = 03-24-2004 1080018000 = 03-23-2004 1079931600 = 03-22-2004 1079845200 = 03-21-2004 1079758800 = 03-20-2004 1079672400 = 03-19-2004 1079586000 = 03-18-2004 1079499600 = 03-17-2004 1079413200 = 03-16-2004 1079326800 = 03-15-2004 1079240400 = 03-14-2004 1079154000 = 03-13-2004 1079067600 = 03-12-2004 1078981200 = 03-11-2004 Tested on PHP 4.3.4 on Win2K. -- Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php