gausie Posted March 11, 2007 Share Posted March 11, 2007 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 https://forums.phpfreaks.com/topic/42177-solved-work-out-what-dates-fridays-in-a-month-are/ Share on other sites More sharing options...
per1os Posted March 11, 2007 Share Posted March 11, 2007 PHP.NET look up the function "mktime" --FrosT Link to comment https://forums.phpfreaks.com/topic/42177-solved-work-out-what-dates-fridays-in-a-month-are/#findComment-204611 Share on other sites More sharing options...
gausie Posted March 11, 2007 Author Share Posted March 11, 2007 How with mktime could I work out what the date of each Friday in a month was? Gausie Link to comment https://forums.phpfreaks.com/topic/42177-solved-work-out-what-dates-fridays-in-a-month-are/#findComment-204712 Share on other sites More sharing options...
Barand Posted March 11, 2007 Share Posted March 11, 2007 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 https://forums.phpfreaks.com/topic/42177-solved-work-out-what-dates-fridays-in-a-month-are/#findComment-204727 Share on other sites More sharing options...
gausie Posted March 11, 2007 Author Share Posted March 11, 2007 Thanks!! Of course, you only need to get the first one, then loop the days! Gausie Link to comment https://forums.phpfreaks.com/topic/42177-solved-work-out-what-dates-fridays-in-a-month-are/#findComment-204728 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.