note 41689 deleted from function.strtotime by derick
| From: | derick@php.net | Date: | Sun, 14 Aug 2005 11:48:02 +0000 |
| Subject: | note 41689 deleted from function.strtotime by derick | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-93585@lists.php.net to get a copy of this message | ||
Note Submitter: aspies at hitwin dot com
----
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
<?php
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));
};
?>