Chinaunix首页 | 论坛 | 博客
  • 博客访问: 126726
  • 博文数量: 6
  • 博客积分: 1400
  • 博客等级: 上尉
  • 技术积分: 515
  • 用 户 组: 普通用户
  • 注册时间: 2006-11-11 03:56
文章分类

全部博文(6)

文章存档

2011年(1)

2008年(5)

我的朋友

分类:

2008-10-16 22:35:43

$endtime="2008-09-09 18:10:00";//date("Y-m-d H:i:s")格式
$d1=substr($endtime,17,2);//秒
$d2=substr($endtime,14,2);//分
$d3=substr($endtime,11,2);//时
$d4=substr($endtime,8,2);//日
$d5=substr($endtime,5,2);//月
$d6=substr($endtime,0,4);//年
$now_T=mktime(date("H"),date("i"),date("s"),date("m"),date("d"),date("Y"));//$now_T=mktime();
$now_S=mktime("$d3","$d2","$d1","$d5","$d4","$d6");
$timeDiff['second']=intval($now_T-$now_S);
$timeDiff['mintue']=round($timeDiff['second']/60);//采用了四舍五入,可以修改
$timeDiff['hour']=round($timeDiff['mintue']/60);
$timeDiff['day']=round($timeDiff['hour']/24);
$timeDiff['week']=round($timeDiff['day']/7);
$timeDiff['month']=round($timeDiff['day']/30);//按30天来算
$timeDiff['year']=round($timeDiff['day']/365);//按365天来算
print_r($timeDiff)."
";
//数据库时间计算
SELECT DATEDIFF(NOW(),`timeItem`) FROM `table` WHERE 1;//得出日差
SELECT (datediff(NOW(),`timeItem`))*24+ (HOUR(NOW())-HOUR(`timeItem`)) FROM `table`  WHERE 1//得出小时差
阅读(1074) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~