note 106065 added to function.date

From: Date: Fri, 07 Oct 2011 05:36:06 +0000
Subject: note 106065 added to function.date
Groups: php.notes 
Request: Send a blank email to php-notes+get-183697@lists.php.net to get a copy of this message
This is how you can get the week starting date and ending date by giving a week number and the year. <?php function week_start_date($wk_num, $yr, $first = 1, $format = 'Y-m-d') { $wk_ts = strtotime('+' . $wk_num . ' weeks', strtotime($yr . '0101')); $mon_ts = strtotime('-' . date('w', $wk_ts) + $first . ' days', $wk_ts); return date($format, $mon_ts); } //Get starting date of week 40 2011 $sStartDate = week_start_date(40, 2011); //Get the ending date of the same week $sEndDate = date('Y-m-d', strtotime('+6 days', strtotime($sStartDate))); //Get current week and year $week = date('w'); $year = date('Y'); ?> ---- Server IP: 69.147.83.197 Probable Submitter: 92.35.237.115 ---- Manual Page -- http://www.php.net/manual/en/function.date.php Edit -- https://master.php.net/note/edit/106065 Del: integrated -- https://master.php.net/note/delete/106065/integrated Del: useless -- https://master.php.net/note/delete/106065/useless Del: bad code -- https://master.php.net/note/delete/106065/bad+code Del: spam -- https://master.php.net/note/delete/106065/spam Del: non-english -- https://master.php.net/note/delete/106065/non-english Del: in docs -- https://master.php.net/note/delete/106065/in+docs Del: other reasons-- https://master.php.net/note/delete/106065 Reject -- https://master.php.net/note/reject/106065 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#183697) next »