Re: I would have guessed Oct 31 would be evil...
| From: | DL Neil | Date: | Thu, 08 Nov 2001 00:56:17 +0000 |
| Subject: | Re: I would have guessed Oct 31 would be evil... | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-73830@lists.php.net to get a copy of this message | ||
Hi Chris,
I don't think that the date of 31Oct is evil - particularly not when you seem to be
ground-hogging on the 28th!
Running your code on my system, under WinNT produces the same result.
I'll take a flying leap into the void and suggest that the reason this date (and the
corresponding for last
year) is causing a problem is because it was the day that many parts of the world (including CA)
changed their
clocks from summer time to whatever - and some others vice-versa. In other words it was a day
longer/shorter
than 24 hours!
In employing a string to hold a date, and then using a time function to convert it to a timestamp
before adding
twenty-four hours worth of seconds, which is finally formed back into a string representation of the
date; you
are somewhat stretching the bounds. I guess the continuously repeating date is a 'feature'
of time-travel which
one hopes will not make it through beta-testing and into the shrink-wrapped final product...
As my old grade-school teacher used to say "you can't add apples and oranges" - never
heard of a blender lady!?
The following code offers two 'virtues': (1) it sticks to a unit of days (the metric of
the 'base' string
format), and (2) it exhibits no groundhog day phenomenon:-
while ($currDate <= $endDate) {
echo "$currDate ~".strtotime($currDate)."~".date('Ymd',
strtotime($currDate))."~<br>\n";
$currDate = date('Ymd', strtotime($currDate+1));
}
(extra debug output for fun and enjoyment...) I'll leave you to test out the theory further,
and once
researched, if you feel it appropriate, to submit a bug report.
Regards,
=dn
----- Original Message -----
From: "Chris Hobbs" <chobbs@silvervalley.k12.ca.us>
To: <php-general@lists.php.net>
Sent: 07 November 2001 19:48
Subject: [PHP] I would have guessed Oct 31 would be evil...
> OK, this is weird! Simplified this to it's bare essentials:
>
> $startDate = "20011031";
> $endDate = "20011115";
> $currDate = $startDate;
>
> while ($currDate <= $endDate) {
> echo "$currDate<br>\n";
> $currDate = date('Ymd', strtotime($currDate)+(24*3600));
> }
> echo "Done!";
>
> This works the way it's written. However, change the startDate so that
> 20011028 is included in the loop, and it never advances past Oct. 28.
> Any other 28th of the month seems to work fine.
>
> Oddly enough, Oct. 29th of last year causes the same problem. What have
> I done wrong?
>
> --
> _______ ___ _ ____ _____
> Chris Hobbs / ____\ \ / / | | |/ ___\| __ \
> Head Geek | (___ \ \ / /| | | | (___ | | | |
> WebMaster \___ \ \ \/ / | | | |\___ \| | | |
> PostMaster ____) | \ / | |__| |____) | |__| |
> \____/ \/ \____/ \____/|_____/
> http://www.silvervalley.k12.ca.us
> chobbs@silvervalley.k12.ca.us
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>