Re: Determining number of days in a selected month

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



date("t") will give you the number of days in the current month.

Or you can do:

date("t", mktime(0, 0, 0, $month, $day, $year))


to get the number of days in a specific month in a specific year (that way you can get leap year accurate counts..)

-TG

= = = Original message = = =

Is there a way to easily tell PHP how many days there are in a selected
month without writing the following out for each month:

if($Month == "January") 
~$NumberOfDays = 31;

elseif($Month == "February") 
~if($Year == "A Leap Year") 
~~$NumberOfDays = 29;
~
~elseif($Year != "A Leap Year") 
~~$NumberOfDays = 28;
~

elseif($Month == "March") 
~$NumberOfDays = 31;

............and so on, and so on, and so on

I would greatly appreciate any help.  Thanks.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux