Jump to content

date();


phpllama

Recommended Posts

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

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.