<?php
function DateDiff($d1,$d2){
if(is_string($d1))$d1=strtotime($d1);
if(is_string($d2))$d2=strtotime($d2);
return ($d2-$d1)/86400;
}
echo DateDiff("2009-09-12","2009-09-27")."<br/>";
function DateAdd($n,$d){
if(is_string($d))$d=strtotime($d);
return Date("Y-m-d",$d+$n*86400);
}
echo DateAdd(21,"2009-10-15")."<br/>";
?>
距离10月25日还有多少天:
<?
$date = date("Y-m-d");
$date1 = "2009-10-25";
//echo strtotime($date)."<br>";
//echo strtotime($date1)."<br>";
$date2 = strtotime($date1)-strtotime($date);
$tianshu=$date2/60/60/24;
?>