|
Posted by Geoff Berrow on 07/08/06 10:20
Message-ID: <icvua2tpe6d6gml7dm5opbgel3mn0mjc9n@4ax.com> from Geoff
Berrow contained the following:
>I need to work on it a little more because some events are of the form,
>last friday, which can be either the 4th or 5th Friday in the month.
I think I have it now
<?php
//sets whether to count from beginning or end
$from_beginning=false;
//position of day from beginning or end
$position=1;
//day
$day="Fri";
//year
$year=2006;
//So with this setting we are looking for the last Friday in each month
for($j=1;$j<13;$j++){
$found=false;
for($i=1;$i<31;$i++){
$stamp=mktime( 0, 0, 0, $j, $i, $year);
if( date("D",$stamp)==$day){
$dates[$j][]=$stamp;
}
}
}
echo "<strong>Dates</strong><br>";
foreach($dates as $key=>$value){
if(!$from_beginning){
//find last day
$ts=$dates[$key][(count($dates[$key])-$position)];
}
else{
$ts=$dates[$key][($position-1)];
}
if($ts>strtotime('now')){
echo date("D F d",$ts)."<br>";
}
}
?>
--
Geoff Berrow 0110001001101100010000000110
001101101011011001000110111101100111001011
100110001101101111001011100111010101101011
Navigation:
[Reply to this message]
|