Reply to Re: Second Saturday?

Your name:

Reply:


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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация