Re: What's with 2016-11-06

From: Date: Tue, 25 Oct 2016 17:52:16 +0000
Subject: Re: What's with 2016-11-06
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-325775@lists.php.net to get a copy of this message
For what it's worth, to modify the code you originally posted, don't calculate: Replace: $calday = $calday + (60 * 60 * 24); With: $calday = strtotime('+1 day', $calday); On Tue, Oct 25, 2016 at 9:10 AM, Cliff Nieuwenhuis <c.nieuwenhuis@adcidesign.com> wrote: > This is a stripped-down version of a calendar program. Can anyone explain why November 6 2016 > appears twice? Or 2015-11-01? > > I'm assuming the fault lies with > > $calday = $calday + (60 * 60 * 24); > > ...but I'd like to know why some days apparently have less than 86400 seconds and how > (efficiently) to work around that. > > Here is my code: > > $calday = strtotime('2016-10-30'); > $finish = strtotime('2016-12-01'); > > while ( $calday < $finish ) { > for ($dow = 0; $dow < 7; $dow++) { > > // set the year, month, and day > $year = (int) date('Y', $calday); > $month = (int) date('n', $calday); > $day = (int) date('j', $calday); > > echo "Year: $year, Month: $month, Day: $day, Day of Week: $dow > <br />\n"; > > // move on to the next day > $calday = $calday + (60 * 60 * 24); > } > echo "* * *<br />\n"; > } > > Thanks in advance for any help. > > -- > Clifford R. Nieuwenhuis > IT Manager > Architectural Design Consultants, Inc. > c.nieuwenhuis@adcidesign.com > 608-254-6181 > > > -- > > Clifford R. Nieuwenhuis > IT Manager > Architectural Design Consultants, Inc. > c.nieuwenhuis@adcidesign.com > 608-254-6181 > > Visit our redesigned website: > www.adcidesign.com > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#325775) next »