RE: [PHP-INSTALL] December 31, 2004
| From: | Tom Haddon | Date: | Tue, 04 Jan 2005 01:01:15 +0000 |
| Subject: | RE: [PHP-INSTALL] December 31, 2004 | ||
| Groups: | php.install | ||
| Request: | Send a blank email to php-install+get-14970@lists.php.net to get a copy of this message | ||
I apologize. Lousy coding there....
I now realise that I need to convert the dates with mktime before I compare them...
Doh!!
-----Original Message-----
From: Tom Haddon [mailto:thaddon@equilar.com]
Sent: Monday, January 03, 2005 4:34 PM
To: php-install@lists.php.net
Subject: [PHP-INSTALL] December 31, 2004
Hi Folks,
I'm experiencing a strange issue with dates for December 31, 2004.
Here's the script:
<?php
$startdate="12/30/2004";
$enddate="12/30/2004";
$dates=array();
$orig=$startdate;
do {
array_push($dates,$startdate);
$startdate=date("m/d/Y",strtotime("+1
day",mktime(0,0,0,substr($startdate,0,2),substr($startdate,3,2),substr($startdate,6,4))));
} while($startdate<=$enddate);
print_r($dates);
?>
If I use the start and end dates as above, everything's great - the $dates array holds one
value, "12/30/2004". But if I change both the start and end date to "12/31/2004"
everything goes awry - I now get an array holding values from "12/31/2004" to
"12/30/2005" - 364 in total!?!?! Any suggestions. Why is "12/31/2004" such a
problem?
Thanks, Tom
---------------------------------------
Tom Haddon
Equilar, Inc.
1710 South Amphlett Boulevard
Suite 312
San Mateo, CA 94402
650-286-4528 (phone)
650-286-4513 (fax)
thaddon@equilar.com
CONFIDENTIALITY NOTICE:
This is a transmission from Equilar, Inc. and may contain information which is confidential and
proprietary. If you are not the addressee, any disclosure, copying or distribution or use of the
contents of this message is expressly prohibited. If you have received this transmission in error,
please destroy it and notify us immediately at 650-286-4512. Internet and e-mail communications are
Equilar's property and Equilar reserves the right to retrieve and read any message created,
sent and received.