note 41689 added to function.strtotime
| From: | aspies at hitwin dot com | Date: | Tue, 20 Apr 2004 00:18:40 +0000 |
| Subject: | note 41689 added to function.strtotime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-68349@lists.php.net to get a copy of this message | ||
In PHP Version 4.2.2 the following statements are equal:
strtotime("next Monday", $date) = strtotime("first Monday", $date) or
strtotime("next Monday", $date) = strtotime("1 Monday", $date) or
strtotime("next Monday", $date) = strtotime("Monday", $date)
By PHP Version 4.3.3 this changed to:
strtotime("next Monday", $date) = strtotime("second Monday", $date) or
strtotime("next Monday", $date) = strtotime("2 Monday", $date)
Obviously the implementation changed according to the GNU standard.
(See also till\at\klimpong\dot\com 26-Feb-2004 03:51 and charlie at brown dot org 21-Jan-2004 05:24)
Be aware, that you have to correct older functions if you are upgrading your PHP-Version. So, for
Example, I have to correct the following helpful function, that was posted somewhere earlier here:
################
# Returns date of the Monday for given number of Iso Week(1..53)
# and year. Output is UNIX-Timestamp
function get_monday ($week, $year="")
{
$first_date = strtotime("1 January ".($year ? $year : date("Y")));
$w_day = date("w", $first_date);
$d_week = 0;
switch($w_day)
{
case 1: $monday = $first_date;
break;
case 2:
case 3:
case 4: $d_week = 604800;
default:$monday = strtotime("Monday", $first_date)-$d_week;
};
$plus_week = "+".($week-1)." week";
return (strtotime($plus_week, $monday));
};
----
Manual Page -- http://www.php.net/manual/en/function.strtotime.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+41689
Delete -- http://master.php.net/manage/user-notes.php?action=delete+41689&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+41689&report=yes
Search -- http://master.php.net/manage/user-notes.php