<?php
/**
* get first monday of the week
*/
function StartOfWeek($year, $week) {
$Jan1 = mktime(1,1,1,1,1,$year);
$MondayOffset = (11-date('w',$Jan1))%7-3;
$desiredMonday = strtotime(($week-1) . ' weeks '.$MondayOffset.' days', $Jan1);
return $desiredMonday;
}
function output_result($week_of_year, $short = false) {
$tmp = StartOfWeek(date("Y"), $week_of_year);
$sStartDate = date ("F d, Y", $tmp);
$sEndDate = date ("F d, Y", $tmp + (6*24*60*60));
if ( $short == false ) {
print "week of <b>$sStartDate - $sEndDate</b> - ";
}
if ( date("L") == 0 ) {
$plastic = 0;
}
else {
$plastic = 1;
}
if ( $week_of_year % 2 == $plastic ) {
print " Plastic";
}
else {
print " Paper";
}
print "\n";
}
?>
<p><?php output_result(date("W")); ?></p>
<p><?php output_result(date("W")+1); ?></p>
Add new comment