Hi,

Ho do i find out which month has how many days with PHP? Ok July is 31 days but, how can i calculate it?

Thanks

Recommended Answers

All 2 Replies

Take a look at the date() function in the PHP Manual ( found at http://au.php.net/manual/en/function.date.php ). There is a special format, t, that returns the number of days in a given month. For example, to find the number of days in July, you could write something like:

$julyDays = date('t', mktime(0, 0, 0, 7, 1, 2008));

since the mktime() function makes a time for the supplied hour, minute, second, month, day and year.

Hope this helps :)

Thanks darkagn. This is what i wanted.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.