Re: Function mktime() documentation question
| From: | Matijn Woudt | Date: | Sun, 11 Mar 2012 19:10:34 +0000 |
| Subject: | Re: Function mktime() documentation question | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-316987@lists.php.net to get a copy of this message | ||
On Sun, Mar 11, 2012 at 7:33 PM, Tedd Sperling <tedd.sperling@gmail.com> wrote:
> On Mar 11, 2012, at 6:12 AM, Ashley Sheridan wrote:
>>
>> I still don't see what's wrong with
>>
>> date("t");
>>
>> --
>> Thanks,
>> Ash
>
> Ash:
>
> It's just too damn simple -- we need to make things complicated. :-)
>
> Actually, this works for me:
>
> $days_in_month = date('t', mktime(0, 0, 0, $next_month, 0, $year));
>
> But again, I don't see why I have to use "next month" to find the number of days
> in this month.
That's because you're requesting day 0 of some month, which refers to
the last day in the previous month.
Try: $days_in_month = date('t', mktime(0, 0, 0, $next_month, 1, $year));
- Matijn