justcode.ikeepstudying.com
PHP计算两个日期内的天数, Javascript 计算两个日期内的天数, Finding the number of days between two dates - Just Code
PHP 版 function dateDiff($start, $end) { $start_ts = strtotime($start); $end_ts = strtotime($end); $diff = $end_ts - $start_ts; return round($diff / 86400); } echo dateDiff("2011-02-15", "2012-01-16").'days'; //Get number of days deference between current date and given date. echo dateDiff("2011-02-15", date('Y-m-d')).'days'; 或者 Javscript 版 // new …