Finding the Date for a Weekday : strtotime « String « PHP






Finding the Date for a Weekday

 
<?php
  echo 'Today is ' . date('d M Y') . '.';
  
  for($i = 1; $i <= 12; $i++)
  {
    $nextmonth = date('Y-' . (date('n') + $i) . '-01');
    $nextmonth_ts = strtotime($nextmonth);
    $firsttue_ts = strtotime("Tuesday", $nextmonth_ts);
    
    echo '<br />The first Tuesday of ' . date('F', $firsttue_ts) 
      . ' is ' . date('d M Y', $firsttue_ts) . '.';
  }
?>
  
  








Related examples in the same category

1.Calculating a date interval with strtotime()
2.Checking a date range
3.int strtotime ( string time [, int now] ) converts strings to a timestamp
4.Using strtotime()
5.Using strtotime() with a starting epoch timestamp
6.Find the First monday on or after November 1, 2008
7.Find weekday
8.Getting the Day and Week of the Year
9.If PHP is unable to convert your string into a timestamp, it will return -1.
10.Obtaining the Difference Between Two Dates
11.Subtracts a year from a given timestamp