Jesus 'n Jim

A mainly PC (some Mac) site w/Software, Computer Repair Info, How-To's on Using Computers
Technical Support 1-360-521-2060 (my business line cell)

php monthly content rotator



for some web sites, people may wish to have some static (or dynamic) content that they wish to display on a certain month.

this can even include text, images, videos, javascript, DHTML, etc. basically, any HTML.


$d = new DateTime(null, new DateTimeZone("America/Los_Angeles"));
$curyr = intval($d->format('Y')); //current year
$curmo = intval($d->format('m')); //current month
$curday = intval($d->format('d')); //current day
$dow = intval($d->format('w')); //day of week. 0 is sunday
$numdow = intval($curday / $wklen); //will be 2 for 3rd thursday. 0-based number of weeks instance of this day of week above.
$fd = new DateTime(sprintf("%04d-%02d-%02d",$curyr,$curmo,1), new DateTimeZone("America/Los_Angeles"));
$fddow = intval($fd->format('w')); //0 is sunday
function findholidayday($dowIn,$wkNumIn) {
	global $curyr,$curmo,$curday,$dow,$numdow,$wklen,$fd,$fddow;
	global $sunday,$monday,$tuesday,$wednesday,$thursday,$friday,$saturday;
	$holidaydowdiff = $dowIn - $fddow;
	if ($fddow > $dowIn) {
		return 1 + $wkNumIn*$wklen + $holidaydowdiff;
	} else {
		return 1 + ($wkNumIn - 1)*$wklen + $holidaydowdiff;

//thanksgiving: 4th thursday of November (and by the way, thursday is dow 4)
$thanksgivingdow = $thursday;
$thanksgivingday = findholidayday($thursday,4);

//day of prayer: 1st thursday of May (and by the way, thursday is dow 4)
$prayerdow = $thursday;
$prayerday = findholidayday($thursday,1);

//father's day: 3rd sunday of June (and by the way, sunday is dow 0)
$fathersdow = $sunday;
$fathersday = findholidayday($sunday,3);

//columbus' day: 2nd monday of October (and by the way, monday is dow 1)
$columbusdow = $monday;
$columbusday = findholidayday($monday,2);

//labor day: 1st monday of September (and by the way, monday is dow 1)
$labordow = $monday;
$laborday = findholidayday($monday,1);

switch($curmo) {
	case 1:
		if (1==$curday) {echo "<h2>Happy New Year!</h2>";}
		if ($curday > 1) {echo "<h2>The New Year, ".$curyr." is here!</h2>";}
		echo "<p><img src='/images/snow.jpg'></p>";
	case 2:
		if ($curday < 14) {echo "<h2>Valentine's Day is on the 14th.</h2>";}
		if (14==$curday) {echo "<h2>Happy Valentine's Day!</h2>";}
	case 3:
		if (17==$curday) {echo "<h2>Happy St. Patrick's Day!</h2>";}
	case 4:
		echo "<h2>Good Friday</h2>";
		echo "<p>National Day of Prayer is on May ".$prayerday."</p>";
	case 5:
		if ($curday < $prayerday) {echo "<p>National Day of Prayer is on May ".$prayerday."</p>";}
		if ($curday == $prayerday) {echo "<p>Today is National Day of Prayer!</p>";}
		echo "<h2>Honor Our Veterans!</h2>";
	case 6:
		if ($curday < $fathersday) {echo "<h2>Father's Day is on June ".$fathersday."</h2>";}
		if ($curday == $fathersday) {echo "<h2>Today is Father's Day! Happy Father's Day!</h2>";}
	case 7:
		if ($curday < 4) {echo "<h2>Independence Day is on July 4th!</h2>";}
		if (4 == $curday) {echo "<h2>Happy Independence Day!</h2>";}
	case 9:
		if ($curday < $laborday) {echo "<h2>Labor Day is on June ".$laborday."</h2>";}
		if ($curday == $laborday) {echo "<h2>Today is Labor Day! Happy Labor Day!</h2>";}
		echo "<h2></h2>";
		echo "<p><img src='/images/autumn.jpg'></p>";
	case 10:
		if ($curday < $columbusday) {echo "<h2>Columbus Day is on October ".$columbusday."</h2>";}
		if ($curday == $columbusday) {echo "<h2>Happy Columbus Day!</h2>";}
		echo "<p><img src='/images/autumn.jpg'></p>";
	case 11:
		if ($curday < $thanksgivingday) {echo "<h2>Happy Thanksgiving! (USA November ".$thanksgivingday.")</h2>";}
		if ($curday == $thanksgivingday) {echo "<h2>Today is Thanksgiving Day! Happy Thanksgiving!</h2>";}
	case 12:
		//occurs every year near Christmas, but give everyone enough notice by doing whole month of December
		if ($curday < 24) {echo "<h2>Christmas is coming December 24th! Merry Christmas!</h2>";}
		if (24 == $curday) {echo "<h2>Christmas Eve! Merry Christmas!</h2>";}
		if (25 == $curday) {echo "<h2>Christmas Day! Merry Christmas!</h2>";}
		if ($curday > 25) {echo "<h2>Merry Christmas and Happy New Year! Happy ".($curyr+1)."!</h2>";}
		echo "<p style='text-align:center;'><a href='' class='userext' target='_blank'>".$curyr." - A Living Nativity Pageant (Vancouver, WA)</a></p>";
		echo "<p><img src='/images/snow.jpg'></p>";