计算剩余天数 [英] Calculate number of days remaining

查看:210
本文介绍了计算剩余天数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想计算一个日期之前剩余的天数。在我的数据库中,我有一个对应于结束日期的时间戳。例如星期五30.我想说这样的话:

I would like to calculate the number of days remaining before a date. In my database I have a timestamp corresponding to the end date. For example Friday 30. I would like to say something like that :

剩下7天... 6,5,4等等

7 days remaining... 6, 5, 4, etc

你能帮我吗?

推荐答案

$future = strtotime('21 July 2012'); //Future date.
$timefromdb = //source time
$timeleft = $future-$timefromdb;
$daysleft = round((($timeleft/24)/60)/60); 
echo $daysleft;

这篇关于计算剩余天数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆