/*
* 功能: 根据输入的年月日 格式化天
* 输入: $tmpYear ->年
$tmpMon ->月
$tmpDay ->
* 返回: $tmpDay ->格式化后的天
*/
function getDayByMon($tmpYear,$tmpMon,$tmpDay)
{
if (is_numeric($tmpDay) && $tmpDay <= 31)
{
switch ($tmpMon)
{
case 2:
if ($tmpDay >= 29)
if ($this->getLeapYear($tmpYear))
$tmpDay = 29;
else
$tmpDay = 28;
case 4:
case 6:
case 9:
case 11:
if ($tmpDay > 30)
$tmpDay = 30;
}
return $tmpDay;
}
else
return false;
}
* 功能: 根据输入的年月日 格式化天
* 输入: $tmpYear ->年
$tmpMon ->月
$tmpDay ->
* 返回: $tmpDay ->格式化后的天
*/
function getDayByMon($tmpYear,$tmpMon,$tmpDay)
{
if (is_numeric($tmpDay) && $tmpDay <= 31)
{
switch ($tmpMon)
{
case 2:
if ($tmpDay >= 29)
if ($this->getLeapYear($tmpYear))
$tmpDay = 29;
else
$tmpDay = 28;
case 4:
case 6:
case 9:
case 11:
if ($tmpDay > 30)
$tmpDay = 30;
}
return $tmpDay;
}
else
return false;
}
$y - 年date("t",mktime(0,0,0,$m,1,$y));
//echo get_date('2006-7-22', '2006-8-22');
function get_date($d1,$d2)
{
$t1 = strtotime($d1);
$t2 = strtotime($d2);
$t = $t1-$t2;
if($t<0)
$t = $t*(-1);
$day = $t/3600/24;
return $day;
}
//计算日期的前N天,
//echo post_date('2006-7-22',10);
function post_date($date, $days) {
$t1 = strtotime($date);
$t2 = $t1 - $days*3600*24;
return date("Y-m-d", $t2);
}
// 指定月的天数
function numMonth($date){
if($date == ""){
$mdate = time();
}else{
$mdate = strtotime($date);
}
$this->numMonth = date("t",$mdate);
return $this->numMonth;
}
http://community.csdn.net/expert/Topicview2.asp?id=5142002
$lastDay = date("j",mktime(0, 0, 0, date("n",time())+1, 0, date("Y",time())));
echo $lastDay;
?>