Page 1 of 1

Getting end of month

Posted: Tue Jan 04, 2011 6:29 pm
by JKM
Hi there,

I'm using mktime(0, 0, 1, $i, 1, $year), and I was wondering how I can find the unix time for 23:59:59 at the last day of the same month ($i).

Thanks.

Re: Getting end of month

Posted: Wed Jan 05, 2011 4:29 am
by Darhazer
JKM wrote:Hi there,

I'm using mktime(0, 0, 1, $i, 1, $year), and I was wondering how I can find the unix time for 23:59:59 at the last day of the same month ($i).

Thanks.
You can use date('t') to find number of days. Or you can use the fact that if you pass negative number to mktime, it will go to the previous month correctly
mktime(23,59,59, $i+1, -1, $year)