php查询还有多少天的方法 1. 创建一个php示例文件; 2. 通过“function countdays($d){...}”方法计算到指定日期还有多少天即可。
本文操作环境windows7系统,php7.1版,dell g3电脑。
php怎么查询还有多少天?
php计算到指定日期还有多少天的方法
代码具体如下
function countdays($d){ $olddate = substr($d, 4); $newdate = date(y) ..$olddate; $nextyear = date(y)+1 ..$olddate; if($newdate > date(y-m-d)) { $start,ts = strtotime($newdate); $end,ts = strtotime(date(y-m-d)); $diff = $end,ts - $start,ts; $n = round($diff / 86400); $return = substr($n, 1); return $return; } else { $start,ts = strtotime($nextyear); $end,ts = strtotime(date(y-m-d)); $diff = $end,ts - $start,ts; $n = round($diff / 86400); $return = substr($n, 1); return $return; }}推荐学习《php视频教程》