note 41689 modified in function.strtotime by aidan

From: Date: Sat, 05 Jun 2004 04:33:14 +0000
Subject: note 41689 modified in function.strtotime by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-70668@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 <?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)); }; ?> --was-- 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)); }; http://www.php.net/manual/en/function.strtotime.php

« previous php.notes (#70668) next »