I have a bizzare problem with php date function.
code:
$numDays = 8;
$date = strtotime('2010-11-06');
for ($i=1; $i<=$numDays; $i++)
{
$thisDay = date("D, d M Y", $date);
print ($thisDay.'<br>');
$date+=86400; // add one day to timestamp
}
result on my server (local host, windows):
Sat, 06 Nov 2010
Sun, 07 Nov 2010
Mon, 08 Nov 2010
Tue, 09 Nov 2010
Wed, 10 Nov 2010
Thu, 11 Nov 2010
Fri, 12 Nov 2010
Sat, 13 Nov 2010
Result on my web server (linux)
Sat, 06 Nov 2010
*Sun, 07 Nov 2010
Sun, 07 Nov 2010*
Mon, 08 Nov 2010
Tue, 09 Nov 2010
Wed, 10 Nov 2010
Thu, 11 Nov 2010
Fri, 12 Nov 2010
Notice how Sun, 07 Nov 2010 appears twice on the remote server?? Why is this happening? can anyone explain this Behavior?
November 7, 2010 is the DST switch date in many time zones (but not Greece where you seem to be located). From Wikipedia:
Starting in 2007, most of the United States and Canada observe DST from the second Sunday in March to the first Sunday in November, almost two-thirds of the year.
In Greece, it seems to be October 31. Which time zone do you have you set on your machine?
It's good practice to do time calculations in UTC and then convert them to the required timezone for the user's location using PHPs datetime functions:
date_default_timezone_set('UTC');
$timezone = new DateTimeZone('Europe/Athens');
$datetime = new DateTime('now', $timezone);
echo $datetime->format('Y-m-d H:i:s');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With