Monday, April 24, 2006

Find numbers of day in a month

Well, that may be a tricky question but if you are oversmart, well that is no problem at all. take a look at the following code


//total number of days in march, 2006
echo Date("t",strtotime("04/0/2006"));
?>


so do you get the point? when you just set the day=0, that also means the last day of previous month.

Dont use "d" in your dateformat string cause it wont return the expected value for PHP 5.1.1 and laters. Use "t" which works pretty fine for all PHP versions.

0 Comments:

Post a Comment

<< Home