Jump to content

[SOLVED] Work out what dates fridays in a month are


gausie

Recommended Posts

Array
(
      [0] => 17:28
      [1] => 17:40
      [2] => 17:52
      [3] => 18:04
      [4] => 19:16
)

 

I know that 0 in the array is a value corresponding to the first Friday in this month, 1 to the second Friday etc..

 

I want to change the key to the UNIX timestamp of the day its referring to.

 

Any help would be graciously appreciated

 

Thanks

 

Gausie

try

<?php
$month = 3;

$m1 = mktime(0,0,0,$month,1,date('Y'));       // date of 1st of month
$dow = date('w', $m1);                        // day of week
$offset = (12 - $dow )%7;                     // how far away is next friday
$f1 = strtotime("+$offset days", $m1);        // get 1st friday date
while (date('m', $f1) == $month ) {           // loop through fridays in month
    echo date('Y-m-d', $f1), '<br/>';
    $f1 = strtotime("+7 days", $f1);
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.