Re: Function mktime() documentation question

From: Date: Mon, 12 Mar 2012 20:07:17 +0000
Subject: Re: Function mktime() documentation question
References: 1 2 3 4 5 6 7 8 9 10  Groups: php.general 
Request: Send a blank email to php-general+get-316996@lists.php.net to get a copy of this message
On Mon, 2012-03-12 at 15:53 -0400, Tedd Sperling wrote: > On Mar 11, 2012, at 3:10 PM, Matijn Woudt wrote: > > On Sun, Mar 11, 2012 at 7:33 PM, Tedd Sperling <tedd.sperling@gmail.com> wrote: > >> 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 > > I got that. > > Beating the same dead horse again, I think day 0 of this month should contain the days in this > month, but I am in the minority on this. > > Cheers, > > tedd > > _____________________ > tedd.sperling@gmail.com > http://sperling.com > I think a lot of the confusion is that we're so used to array indexes beginning at 0 that we tend to assume other things should start there too. I found this confusing when I first came across the date stuff in PHP. Now I'm used to it, it makes sense. -- Thanks, Ash http://www.ashleysheridan.co.uk

« previous php.general (#316996) next »