note 92756 modified in function.strtotime by danbrown

From: Date: Fri, 07 Aug 2009 14:44:10 +0000
Subject: note 92756 modified in function.strtotime by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-159186@lists.php.net to get a copy of this message
strtotime() also returns time by year and weeknumber. (I use PHP 5.2.8, PHP 4 does not support it.) Queries can be in two forms: - "yyyyWww", where yyyy is 4-digit year, W is literal and ww is 2-digit weeknumber. Returns timestamp for first day of week (for me Monday) - "yyyy-Www-d", where yyyy is 4-digit year, W is literal, ww is 2-digit weeknumber and dd is day of week (1 for Monday, 7 for Sunday) <?php // Get timestamp of 32nd week in 2009. strtotime('2009W32'); // returns timestamp for Mon, 03 Aug 2009 00:00:00 // Weeknumbers < 10 must be padded with zero: strtotime('2009W01'); // returns timestamp for Mon, 29 Dec 2008 00:00:00 // strtotime('2009W1'); // error! returns false // See timestamp for Tuesday in 5th week of 2008 strtotime('2008-W05-2'); // returns timestamp for Tue, 29 Jan 2008 00:00:00 ?> Weeknumbers are (probably) computed according to ISO-8601 specification, so doing date('W') on given timestamps should return passed weeknumber. --was-- strtotime() also returns time by year and weeknumber. (I use PHP 5.2.8, PHP 4 does not support it.) Queries can be in two forms: - "yyyyWww", where yyyy is 4-digit year, W is literal and ww is 2-digit weeknumber. Returns timestamp for first day of week (for me Monday) - "yyyy-Www-d", where yyyy is 4-digit year, W is literal, ww is 2-digit weeknumber and dd is day of week (1 for Monday, 7 for Sunday) <? // Get timestamp of 32nd week in 2009. strtotime('2009W32'); // returns timestamp for Mon, 03 Aug 2009 00:00:00 // Weeknumbers < 10 must be padded with zero: strtotime('2009W01'); // returns timestamp for Mon, 29 Dec 2008 00:00:00 // strtotime('2009W1'); // error! returns false // See timestamp for Tuesday in 5th week of 2008 strtotime('2008-W05-2'); // returns timestamp for Tue, 29 Jan 2008 00:00:00 ?> Weeknumbers are (probably) computed according to ISO-8601 specification, so doing date('W') on given timestamps should return passed weeknumber. http://php.net/manual/en/function.strtotime.php

« previous php.notes (#159186) next »