You are here: Re: Second Saturday? « All PHP « IT news, forums, messages
Re: Second Saturday?

Posted by Joe on 10/10/56 11:52

In article <kl1va25dj9shaun28knjk1o3o0mrc935je@4ax.com>,
blthecat@ckdog.co.uk says...
> Message-ID: <icvua2tpe6d6gml7dm5opbgel3mn0mjc9n@4ax.com> from Geoff
> Berrow contained the following:
>

>
> 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>";
> }
> }
> ?>
>
Looks good! Thanks for that.

 

Navigation:

[Reply to this 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

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