RE: [PHP] date brain teaser
| From: | esctoday.com | Wouter van Vliet | Date: | Fri, 03 Oct 2003 02:03:56 +0000 |
| Subject: | RE: [PHP] date brain teaser | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-164840@lists.php.net to get a copy of this message | ||
You'd probably be able to get the first Friday in a year with smth like:
$Friday = strtotime("First Friday in 2003"); And if you go for the "count 7
days up" method .. Pitfall could be forgetting to check if you're still in
the year you started in.
Hope I added something valueable ;)
-----Original Message-----
From: Martin Towell [mailto:martin.towell@world.net]
Sent: Friday, October 03, 2003 3:18 AM
To: 'J Morton'; Shew; php-general@lists.php.net
Subject: RE: [PHP] date brain teaser
How about something similar, but look for the first Friday and then add
seven days (or 604800 seconds) to get the date of the next Friday?
-----Original Message-----
From: J Morton [mailto:jwm@justinmorton.com]
Sent: Friday, 3 October 2003 11:20 AM
To: Shew; php-general@lists.php.net
Subject: Re: [PHP] date brain teaser
Sure --
<?
$this_date = "1/1/2003";
for($i=1; $i<=365; $i++) {
if (date("l", strtotime($this_date) == "Friday")) {
echo $this_date . "<br>";
}
$this_date = date("n/j/Y",mktime(0,0,0,date("m",
strtotime($this_date)),date("d", strtotime($this_date))+1,date("Y",
strtotime($this_date))));
}
?>
Shew wrote:
> Hi,
>
> I'm trying to find a formula for displaying the date for every Friday of a
> given year, i.e. 2003
>
> Jan 3, 2003
> Jan 10, 2003
> Jan 17, 2003
> etc.
>
> Any ideas?
>
> Thanks
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
__________ Information from NOD32 1.518 (20030925) __________
This message was checked by NOD32 for Exchange e-mail monitor.
http://www.nod32.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php