迅睿开源框架是一款PHP8高性能·简单易用的PHP开源开发框架, 基于MIT开源许可协议发布,不限制商业使用,以多端互联为设计理念, 支持的微信公众号、小程序、APP客户端、移动端网站、PC网站等多终端式管理系统。
如何调用指定时间还剩下多少天?
比如日期字段填写了 2020-10-01,,如果调出,距离今天还有多少天?
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 $Date_1=date("Y-m-d"); $Date_2="$daoqiriqi"; $d1=strtotime($Date_1); $d2=strtotime($Date_2); $Days=round(($d1-$d2)/3600/24); echo ".$Days.""; ?>
相差{$Days=round((strtotime(date("Y-m-d"))-strtotime($daoqiriqi))/3600/24);}天
相差{$date=floor((strtotime($daoqiriqi)-strtotime(date("Y-m-d")))/86400);}天
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 $Date_1=date("Y-m-d"); $Date_2="$daoqiriqi"; $d1=strtotime($Date_1); $d2=strtotime($Date_2); $Days=round(($d1-$d2)/3600/24); echo ".$Days.""; ?>相差{$Days=round((strtotime(date("Y-m-d"))-strtotime($daoqiriqi))/3600/24);}天但为什么输出的相差多少天前面会有一个-号相差{$date=floor((strtotime($daoqiriqi)-strtotime(date("Y-m-d")))/86400);}天