求两个日期的差数,例如2015-2-25,2015-7-22的日期差

<?php
function between ($day1, $day2) {
    if(strtotime($day1) < strtotime($day2)){
        return (strtotime($day2) - strtotime($day1))/86400;
    } else {
        return (strtotime($day1) - strtotime($day2))/86400;
    }
}
echo between ("2015-2-25", "2015-7-22");

输出:147

发表评论

Close Menu