note 89165 added to function.date
| From: | pierre at osu1 dot php dot net | Date: | Tue, 24 Feb 2009 22:22:06 +0000 |
| Subject: | note 89165 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-151084@lists.php.net to get a copy of this message | ||
It seems to me that you can reliably get the week range of a certain numeric week like so:
<?php
// 2009 is the year
// W01 is week number 1
// 1 is the day number (Monday), 7 would be Sunday
strtotime("2009W011");
// Example 1 (These return the days for Week 1 or 2009
Mon_timestamp = strtotime("2009W011");
Tue_timestamp = strtotime("2009W012");
Wed_timestamp = strtotime("2009W013");
Thu_timestamp = strtotime("2009W014");
Fri_timestamp = strtotime("2009W015");
Sat_timestamp = strtotime("2009W016");
Sun_timestamp = strtotime("2009W017");
// Example 2 (more dynamic)
// set the 7 dates of the week
for($i=1; $i<=7; $i++) {
$dates[$i] = strtotime($year.'W'.$week.$i);
}
?>
Just remember you must pad the week number if it's under 10. 1 won't work, it should be
01.
----
Server IP: 202.158.52.162
Probable Submitter: 114.58.219.199
----
Manual Page -- http://www.php.net/manual/en/function.date.php
Edit -- https://master.php.net/note/edit/89165
Del: integrated -- https://master.php.net/note/delete/89165/integrated
Del: useless -- https://master.php.net/note/delete/89165/useless
Del: bad code -- https://master.php.net/note/delete/89165/bad+code
Del: spam -- https://master.php.net/note/delete/89165/spam
Del: non-english -- https://master.php.net/note/delete/89165/non-english
Del: in docs -- https://master.php.net/note/delete/89165/in+docs
Del: other reasons-- https://master.php.net/note/delete/89165
Reject -- https://master.php.net/note/reject/89165
Search -- https://master.php.net/manage/user-notes.php