Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loop days in a month? 2

Status
Not open for further replies.

Tokhra

Programmer
Oct 1, 2003
134
ES
Hi all,

How would you retrieve the number of days in a month dynamically with php?

Thanks,
Matt.
 
php's date() funtion is very good.

Code:
<?php 
echo date('t');
?>

______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
KarveR's example prints out the number of days in the current month (at execution time). If you want a different date you also have to pass a second argument that provides the date to be examined. There are many ways to supply that, as a UNIX timestamp, a string transformed into a date with strtotime() etc.
 
Thanks for the responses KarveR and DRJ478. I regularly use the mktime and date functions but never realised date could tell you how many days in a month :s, I ended up using an array to store days in month hard coded.

Oh well, I'll know for next time :)

Thanks Again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top