note 13595 deleted from function.mktime by vincent
| From: | vincent@php.net | Date: | Wed, 10 Sep 2003 19:11:59 +0000 |
| Subject: | note 13595 deleted from function.mktime by vincent | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-56016@lists.php.net to get a copy of this message | ||
Note Submitter: johnjc@lineone.net
----
witt, about a month ago, made a good addition to the documentation when he posted code showing how
to get future dates using mktime() and date(), which manual says you can do but offers no examples.
However, the code he posted gives you next Saturday and last Sunday, which I don't think was
what was intended. But thanks again to witt because he made me think, too. :)
To get the dates for the next weekend, at any time during the week, you can use the code below.
(I'm in Europe and my server is in the US so gmmktime() and gmdate() are more useful to me.
$sun =
gmmktime(0,0,0,gmdate("m"),(gmdate("d")+(7-gmdate("w"))),gmdate("Y"));
$sat =
gmmktime(0,0,0,gmdate("m"),(gmdate("d")+(6-gmdate("w"))),gmdate("Y"));