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

June 2017





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)); ?>

Related


Published by jak58. Latest update on October 24, 2009 at 02:40 AM by jak58.
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).