Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>PHP</strong></p> <pre><code>$week_number = 40; $year = 2008; for($day=1; $day&lt;=7; $day++) { echo date('m/d/Y', strtotime($year."W".$week_number.$day))."\n"; } </code></pre> <p><hr> Below post was because I was an idiot who didn't read the question properly, but will get the dates in a week starting from Monday, given the date, not the week number..</p> <p><strong>In PHP</strong>, adapted from <a href="http://ie2.php.net/manual/en/function.date.php#85258" rel="noreferrer">this post</a> on the <a href="http://ie2.php.net/manual/en/function.date.php" rel="noreferrer">PHP date manual page</a>:</p> <pre><code>function week_from_monday($date) { // Assuming $date is in format DD-MM-YYYY list($day, $month, $year) = explode("-", $_REQUEST["date"]); // Get the weekday of the given date $wkday = date('l',mktime('0','0','0', $month, $day, $year)); switch($wkday) { case 'Monday': $numDaysToMon = 0; break; case 'Tuesday': $numDaysToMon = 1; break; case 'Wednesday': $numDaysToMon = 2; break; case 'Thursday': $numDaysToMon = 3; break; case 'Friday': $numDaysToMon = 4; break; case 'Saturday': $numDaysToMon = 5; break; case 'Sunday': $numDaysToMon = 6; break; } // Timestamp of the monday for that week $monday = mktime('0','0','0', $month, $day-$numDaysToMon, $year); $seconds_in_a_day = 86400; // Get date for 7 days from Monday (inclusive) for($i=0; $i&lt;7; $i++) { $dates[$i] = date('Y-m-d',$monday+($seconds_in_a_day*$i)); } return $dates; } </code></pre> <p>Output from <code>week_from_monday('07-10-2008')</code> gives:</p> <pre><code>Array ( [0] =&gt; 2008-10-06 [1] =&gt; 2008-10-07 [2] =&gt; 2008-10-08 [3] =&gt; 2008-10-09 [4] =&gt; 2008-10-10 [5] =&gt; 2008-10-11 [6] =&gt; 2008-10-12 ) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload