On 30 Jul 2002 [EMAIL PROTECTED] wrote: > Yeah, reading a bit more it looks like you are right. I have fixed > this in CVS now. "next" maps to "2" now instead of "1"
Doesn't this break backward compability? Derick > > > Previous Comments: > ------------------------------------------------------------------------ > > [2002-07-30 14:28:58] [EMAIL PROTECTED] > > That's *not* what the spec of strtotime at > http://www.gnu.org/manual/tar-1.12/html_chapter/tar_7.html (linked from > http://www.php.net/manual/en/function.strtotime.php) says. > > I quote: > > "A number may precede a day of the week item to move forward > supplementary weeks. It is best used in expression like `third > monday'." > > and: > > "A few numbers may be written out in words in most contexts. ... Here > is the list: `first' for 1, `next' for 2, `third' for 3, ..." > > implying that "next sunday" should return the *second* Sunday from the > given date. > > And, indeed, the following does exactly what the original poster > intended: > > while($now<$date) { > echo date("l, F j, Y", $now)."<br>"; > $now=strtotime("2 Sunday", $now); > } > > So the problem would appear to be that, notwithstanding the GNU > documentation, the PHP strtotime() interpretation of "next" is not, in > fact, equivalent to 2. > > Cheers! > > Mike > > ------------------------------------------------------------------------ > > [2002-07-30 14:11:57] [EMAIL PROTECTED] > > strtotime() will return the first sunday it finds after the given > timestamp in this case. So you really need to move the timestamp ahead > each time and ask it to find the next Sunday in order to prevent it > from finding the same Sunday again. Or perhaps keep adding 1 week > instead once you found the first one. Watch out for the daylight > savings switchover though. > > ------------------------------------------------------------------------ > > [2002-07-30 13:57:20] [EMAIL PROTECTED] > > The configure line is: > './configure' '--enable-ftp' '--enable-bc-math' > '--enable-gd-native-ttf' '--enable-inline-optimization' > '--enable-mbstring' '--enable-mbstr-enc-trans' '--enable-sysvsem' > '--enable-sysvshm' '--enable-sockets' '--enable-track-vars' > '--enable-trans-sid' '--with-freetype-dir=/usr' '--with-gd=/usr' > '--with-imap=/usr' '--with-imlib=/usr' '--with-jpeg-dir=/usr' > '--with-kerberos=/usr/kerberos' '--with-mysql=/usr/local/mysql' > '--with-openssl=/usr' '--with-png-dir=/usr' '--with-t1lib=/usr' > '--with-ttf=/usr' '--with-xml' '--with-xpm-dir=/usr/X11R6' > '--with-zlib-dir=/usr' '--with-apache=../apache_1.3.26' '--with-snmp' > '--enable-ucd-snmp-hack' > > I was writing a script that was supposed to determine all the Sundays > between an entered date and the current date. I had a loop in which I > used "strtotime("next Sunday",$date)". This did not work and just > returned the sunday after the current date instead of the Sunday after > the timestamp i gave it. I had used an identical expression outside of > the loop and it correctly returned the next Sunday of the timestamp i > gave it. > > This script replicates the problem: > <? > $now=time(); > $date=strtotime("November 24, 2002"); > while($now<$date) { > echo date("l, F j, Y", $now)."<br>"; > $now=strtotime("next Sunday", $now); > } > ?> > > That loop will never terminate as it logically should. > > ------------------------------------------------------------------------ > > > -- > Edit this bug report at http://bugs.php.net/?id=18655&edit=1 > --------------------------------------------------------------------------- Derick Rethans http://www.derickrethans.nl/ JDI Media Solutions http://www.jdimedia.nl/ --------------------------------------------------------------------------- -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, visit: http://www.php.net/unsub.php