phpllama Posted September 25, 2009 Share Posted September 25, 2009 Hi. I'm trying to get my script to produce the date of every Friday of the current month. But I have no idea how to do it $date = time(); $month = date('F', $date); So I've got the current month but how do you get the Friday from every week of the month? Link to comment https://forums.phpfreaks.com/topic/175546-date/ Share on other sites More sharing options...
5kyy8lu3 Posted September 25, 2009 Share Posted September 25, 2009 http://us2.php.net/manual/en/function.date.php Link to comment https://forums.phpfreaks.com/topic/175546-date/#findComment-925105 Share on other sites More sharing options...
cjb Posted September 26, 2009 Share Posted September 26, 2009 This will display every Friday of the current month, use the array $fridays for the unix time. Let me know if you have any questions. $now = time(); $nowYear = date('Y', $now); $nowMonth = date('n', $now); $nowDay = date('j', $now); $uFirstDay = mktime(0,0,0,$nowMonth,1,$nowYear); $uLastDay = mktime(0,0,0,$nowMonth+1, 0, $nowYear); $firstDay = date('D', $uFirstDay); $fridays = array(); $fridaysCount = 0; $day = $uFirstDay; while($day <= $uLastDay){ $weekday = date('D', $day); if($weekday == "Fri"){ $fridays[$fridaysCount] = $day; echo date('D, M j, Y', $day) . "<br>"; $fridaysCount++; } $day = $day + (60*60*24); } echo "<br><br>There are $fridaysCount Fridays this month<br>$fridays[0],$fridays[1],$fridays[2],$fridays[3]"; Link to comment https://forums.phpfreaks.com/topic/175546-date/#findComment-925113 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.