Re: date, "first of next month"?
| From: | Bryan Koschmann - GKT | Date: | Thu, 27 Feb 2003 22:19:37 +0000 |
| Subject: | Re: date, "first of next month"? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-137478@lists.php.net to get a copy of this message | ||
On Wed, 26 Feb 2003, Philip Hallstrom wrote:
|
|Use the w option of date() and loop through adding 86400 to $t until you
|get to a number between 1 and 5.
|
| w - day of the week, numeric, i.e. "0" (Sunday) to "6" (Saturday)
I may of gotten ahead of myself, but I tried it using if/else. Looks like
this:
$t = mktime(0,0,0,date('m')+1,1,date('Y'));
$expdate = date("l, F jS Y", $t);
$expdatenum = date("w", $t);
if ($expdatenum == "6") {
$rendate = date("l, F jS Y", strtotime("$expdate +2 days"));
} else {
$rendate = date("l, F jS Y", strtotime("$expdate +1 day"));
}
I'm not sure if it would be more inefficient or what, but it seems to work
(so far). I'm not too worried about efficiency because it will only run
once a month.
Thanks to everyone who replied! I appreciate all the help!
Bryan