RE: [PHP-WIN] Please Help with incorrect Date Code

From: Date: Mon, 17 Sep 2001 19:29:28 +0000
Subject: RE: [PHP-WIN] Please Help with incorrect Date Code
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-9390@lists.php.net to get a copy of this message
Dean, Thanks for the response Dean, I didn't even think about daylight savings time! Changed the hour on the initial timestamp as you suggested and all is well again ;) Thanks again, Max -----Original Message----- From: Dean Bennett [mailto:dean.bennett@home.com] Sent: Monday, September 17, 2001 11:24 AM To: max Subject: Re: [PHP-WIN] Please Help with incorrect Date Code Someone else discovers daylight savings. Once a year, one day has 25 hours, so 24 hours after 10/28/01 00:00 is 10/28/01 23:00. Use an hour other than 00:00 in your initial timestamp, Or you could just keep incrementing $dy - mktime knows that 10/32 is 11/1. max wrote: > > I'm posting a snippet of code which prints each date within a week. For > example on the day of 10/21/01 it will print the dates 10/21/01, 22, 23, 24, > 25, 26, and 27. > > The problem I am having is on the week of 10/28/01 it will print 10/28 > twice. for example 28,28,29,30,31,1,2,3. As far as I can tell every other > date seems to work fine except for the week of the 28th, where I get the > 28th twice. I'm hoping someone will take a quick look at the code below and > maybe have an idea as to why this is occuring or see something I dont see. > > I greatly appreciate any help or advince. > > Thanks. > > <? > $yr = "2001"; > $mnth = "10"; > $dy = "28"; > > $sunday_stamp = > mktime(0,0,0,$mnth,$dy-date("w",mktime(0,0,0,$mnth,$dy,$yr)),$yr); > $last_sunday = date("Y-m-d", $sunday_stamp); > $next_saturday = > date("Y-m-d",mktime(0,0,0,$mnth,$dy+6-date("w",mktime(0,0,0,$mnth,$dy,$yr)), > $yr)); > > $next_day = $last_sunday; > $next_stamp = $sunday_stamp; > while($next_day <= $next_saturday) > { > $newsplit = explode("-", $next_day); > $date = date("m/d/y", > mktime(0,0,0,$newsplit[1],$newsplit[2],$newsplit[0])); > $dayoweek = date("l", > mktime(0,0,0,$newsplit[1],$newsplit[2],$newsplit[0])); > > echo "$dayoweek $date<BR>"; > > $next_stamp = $next_stamp + 86400; // stamp plus # of seconds in a day > $next_day = date("Y-m-d",$next_stamp);; > } > ?> > > -- > PHP Windows Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net > For additional commands, e-mail: php-windows-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.windows (#9390) next »