วันพฤหัสบดีที่ 28 มีนาคม พ.ศ. 2556

หาจำนวนวัน ในเดือน ของปีใด ๆ


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="">
  A
  <input name="a" type="text" id="a" />
  B
  <input name="b" type="text" id="b" />
  C
  <input name="c" type="text" id="c" />
  <input type="submit" name="Submit" value="Submit" />
</form>
<?
function get_days_in_month($month, $year)
{
   return $month == 2 ? ($year % 4 ? 28 : ($year % 100 ? 29 : ($year %400 ? 28 : 29))) : (($month - 1) % 7 % 2 ? 30 : 31);
}
$myyear = date('Y');
echo get_days_in_month(2, $myyear);
?>
</body>
</html>