Re: pro-rated date
| From: | Tom Rogers | Date: | Tue, 18 Feb 2003 00:21:47 +0000 |
| Subject: | Re: pro-rated date | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-135924@lists.php.net to get a copy of this message | ||
Hi,
Tuesday, February 18, 2003, 7:03:37 AM, you wrote:
PC> Anybody have a quick way of determining the number of days remaining in
PC> the current month?
PC> I'm currently using:
PC> $nextmonth = strftime("%Y-%m-01",strtotime("+1 month"))
PC> $monthdays = strftime("%d",strtotime($nextmonth)-86400);
PC> $daysleft = $monthdays - strftime("%d",time());
PC> I can obviously compact things into a single line, but it's enormous and
PC> offends my sense of esthetics. I was hoping I might be able to feed
PC> something funky like "first day of next month" to strtotime, but the gnu
PC> date input format isn't quite that flexible.
PC> Any advice? Is there an *elegant* way of doing this?
PC> --
PC> Paul Chvostek <paul@it.ca>
PC> Operations / Abuse / Whatever
PC> it.canada, hosting and development
PC> http://www.it.ca/
This might get what you want, but to be accurate you will have to decide what to
do with the odd hours mins left over
$days = (strtotime("+1 month") - (date("d")* 86400) - time()) / 86400;
--
regards,
Tom