随笔-103  评论-37  文章-0  trackbacks-0
function prMonths($dt){
        $onedate = strtotime($dt);
        $months = (date("Y")-date("Y",$onedate))*12+(date("m")-date("m",$onedate));
        return abs($months);
}
echo prMonths('2010-01-01')."\n";

function getMonths($first_date,$last_date) {
    $date1 = strtotime($first_date);
    $date2 = strtotime($last_date);
    $months = (date("Y",$date2) - date("Y",$date1))*12 + (date("m",$date2) - date("m",$date1)) ;
    return abs($months);
}
echo getMonths("2011-12-23","2012-05-24");
posted on 2011-08-04 15:25 鱼有所思 阅读(428) 评论(0)  编辑 收藏 引用 网摘 所属分类: PHP

只有注册用户登录后才能发表评论。
网站导航: