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

Ask a question




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

PHP 5 - Using an external URL with the function include
Mktime() - Timestamp yesterday, last month, etc.).