Source Code for Paper/Plastic

<?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>

Tags: 

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote> <pre>
  • Lines and paragraphs break automatically.
  • Syntax highlight code surrounded by the {syntaxhighlighter SPEC}...{/syntaxhighlighter} tags, where SPEC is a Syntaxhighlighter options string or class="OPTIONS" [title="the title"].

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.