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

Link to comment
Share on other sites

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);
}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.