0
Thanks

A few words of thanks would be greatly appreciated.

PHP - Last day of the month/Number of days in the month





Using $m as the number of the month i and $y as year. Function date() can display directly the number of days in the month using the "t" character:


<?
      $month = mktime( 0, 0, 0, $m, 1, $y ); 
      setlocal ('LC_ALL', 'en_EN');
      echo "The month ".date("F Y",$mois)." Has
 ".date("t",$mois)." days";
?>



You can have this value back using :

<? $numberofdays = intval(date("t",$mois)); ?>
0
Thanks

A few words of thanks would be greatly appreciated.

Ask a question
CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jean-François Pillou, founder of CCM.net. CCM reaches more than 50 million unique visitors per month and is available in 11 languages.
This document, titled « PHP - Last day of the month/Number of days in the month », is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (ccm.net).

0 Comments