文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>可以计算任意时间差的函数

可以计算任意时间差的函数

时间:2007-02-17  来源:PHP爱好者

<?
ww w.china it power.co9NAskd5I1Ip6xoiUvnNuduPvU
function diff($day1,$day2)
ww w.china it power.co9NAskd5I1Ip6xoiUvnNuduPvU
{
ww w.china it power.co9NAskd5I1Ip6xoiUvnNuduPvU
$a=explode("-",$day1);
ww w.china it power.co9NAskd5I1Ip6xoiUvnNuduPvU
$b=explode("-",$day2);
ww w.china it power.co9NAskd5I1Ip6xoiUvnNuduPvU
if(checkdate($a[1],$a[2],$a[0]) && checkdate($b[1],$b[2],$b[0]))
ww w.china it power.co9NAskd5I1Ip6xoiUvnNuduPvU
{
ww w.china it power.co9NAskd5I1Ip6xoiUvnNuduPvU
$c=mktime(0,0,0,$a[1],$a[2],$a[0]);
ww w.china it power.co9NAskd5I1Ip6xoiUvnNuduPvU
$d=mktime(0,0,0,$b[1],$b[2],$b[0]);
ww w.china it power.co9NAskd5I1Ip6xoiUvnNuduPvU
$f=($d-$c)/3600/24;
ww w.china it power.co9NAskd5I1Ip6xoiUvnNuduPvU
echo "$day1 和 $day2 之间相差 $f 天!";
ww w.china it power.co9NAskd5I1Ip6xoiUvnNuduPvU
}
ww w.china it power.co9NAskd5I1Ip6xoiUvnNuduPvU
else
ww w.china it power.co9NAskd5I1Ip6xoiUvnNuduPvU
{
ww w.china it power.co9NAskd5I1Ip6xoiUvnNuduPvU
print "对不起,你的日期格式不对!";
ww w.china it power.co9NAskd5I1Ip6xoiUvnNuduPvU
}
ww w.china it power.co9NAskd5I1Ip6xoiUvnNuduPvU
}
ww w.china it power.co9NAskd5I1Ip6xoiUvnNuduPvU
//用法
ww w.china it power.co9NAskd5I1Ip6xoiUvnNuduPvU
diff("2001-1-1","2001-3-1");
ww w.china it power.co9NAskd5I1Ip6xoiUvnNuduPvU
?>
php爱好者站 http://www.phpfans.net Linux|Apache|IIS.
相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载