php 计算到指定日期还有多少天

感兴趣的小伙伴,下面一起跟随编程之家 jb51.cc的小编来看看吧。
经测试代码如下:

/**
 * 计算到指定日期还有多少天
 *
 * @param 
 * @arrange (编程之家) jb51.cc
 **/
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;

}

}

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...