Re: getting date: howto
| From: | (Richard Lynch) | Date: | Tue, 04 Jul 2000 02:09:04 +0000 |
| Subject: | Re: getting date: howto | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-4648@lists.php.net to get a copy of this message | ||
In article <395E0251.3BD5AF5A@myweb.com.my>, meling@myweb.com.my (spoon
fork) wrote:
> Is there any functions in PHP that I can use to, say,
> determine on what date the first, second, third or fourth Monday
> (or any weekday) is on a particular month?
$month = 7;
$weekday = 1; //Is 1 Monday? Or 2? Or 0? Whatever.
$last = date("t", mktime(0, 0, 0, $month, 1));
for ($day = 1, $nth = 0; $day <= $last; $day++){
$date = mktime(0, 0, 0, $month, $day);
if (date("w", $date) == $weekday && date("m", $date) == $month){
$nth++;
echo "$nth Monday is on $month/$day<BR>\n";
}
}
--
Richard Lynch | If this was worth $$$ to you, buy a CD
US Customer Support Director | from one of the artists listed here:
Zend Technologies USA | http://www.L-I-E.com/artists.htm
http://www.zend.com | (this has nothing to do with Zend,
duh!)