RE: [PHP-INSTALL] December 31, 2004

[email protected] ("Tom Haddon")
Newsgroups php.install
Message-ID <[email protected]>
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:[email protected]]
Sent: Monday, January 03, 2005 4:34 PM
To: [email protected]
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)
[email protected]

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.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.