[TriLUG] Perplexed

Matt Frye mattfrye at gmail.com
Tue Apr 4 12:10:06 EDT 2006


On 4/4/06, Brian Henning <brian at strutmasters.com> wrote:
> ...why aren't you using PHP's built-in date/time functions?

Ok.

But...

echo date("Y-m-d",strtotime("last Monday")), "\n";

yet gives me 2006-04-03 instead of 2006-03-27.  I still have to resort
to a loop to get the right numbers of days back...which is ok because
date() and strtotime do it correctly.

<?php
$day = date("l") ;
print "<br>Day is $day - Before<br>";
switch ($day) {
case "Monday":
   print "<br>Day is $day - During<br>";
   $startdated = date("Y-m-d",strtotime("a week ago")) ;
   break;

and so on.  I still don't understand why the other loop didn't work. 
I guess it doesn't matter.  Thanks Brian.

MPF



More information about the TriLUG mailing list