|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-04-04 09:28 UTC] sveinp at basefarm dot no
[sveinp@ws195 ~]$ php -q
<?PHP
print strftime("%c",strtotime("last saturday")) . "\n";
?>
Fri Mar 29 23:00:00 2002
[sveinp@ws195 ~]$
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 02:00:01 2025 UTC |
Please reset to open. If this was to be closed it, would be 'close' and not 'bogus', as Jani already confirmed it. Today's checkout, HEAD and STABLE: mdev@server21 ~/cvs/php4 $ sapi/cli/php -q <?php $today = mktime(9, 28, 0, 4, 4, 2002); print date("r", $today) . "\n"; print date("r", strtotime("last saturday", $today)) . "\n"; ?> Thu, 4 Apr 2002 09:28:00 +0200 Fri, 29 Mar 2002 23:00:00 +0100 mdev@server21 ~/cvs/php-4.2.3 $ sapi/cli/php -q <?php $today = mktime(9, 28, 0, 4, 4, 2002); print date("r", $today) . "\n"; print date("r", strtotime("last saturday", $today)) . "\n"; ?> Thu, 4 Apr 2002 09:28:00 +0200 Fri, 29 Mar 2002 23:00:00 +0100<?php $today = mktime(9, 28, 0, 4, 7, 2002); print date("r", $today) . "\n"; print date("r", strtotime("last saturday", $today)) . "\n"; ?> ------------ Sun, 7 Apr 2002 09:28:00 -0400 Sat, 6 Apr 2002 00:00:00 -0500 Seems to work fine, even across DST.After a few more tests I was able to replicate the problem, it appears that if I set the date higher then the date on which the change occurs, the functions messes up. For example: <?php $today = mktime(9, 28, 0, 4, 8, 2002); print date("r", $today) . "\n"; print date("r", strtotime("last saturday", $today)) . "\n"; ?> ------------ Mon, 8 Apr 2002 09:28:00 -0400 Fri, 5 Apr 2002 23:00:00 -0500PHP version 4.3.1 reused the code found here recently. <?php $today = mktime(9, 28, 0, 4, 1, 2003); print date("r", $today) . "<BR>"; print date("r", strtotime("last saturday", $today)) . "<BR>"; print date("r", strtotime("last sunday", $today)) . "<BR>"; print date("r", strtotime("last monday", $today)) . "<BR>"; ?> Tue, 1 Apr 2003 09:28:00 +0200 Fri, 28 Mar 2003 23:00:00 +0100 Sat, 29 Mar 2003 23:00:00 +0100 Mon, 31 Mar 2003 00:00:00 +0200 how to handle this? everything before monday seems to get 1 day less.