迅睿開源框架是一款PHP8高性能·簡單易用的PHP開源開發(fā)框架, 基于MIT開源許可協(xié)議發(fā)布,不限制商業(yè)使用,以多端互聯(lián)為設(shè)計理念, 支持的微信公眾號、小程序、APP客戶端、移動端網(wǎng)站、PC網(wǎng)站等多終端式管理系統(tǒng)。
業(yè)務(wù)經(jīng)理
微信掃描以上二維碼
028-61286886
技術(shù)咨詢
如何調(diào)用指定時間還剩下多少天?
比如日期字段填寫了 2020-10-01,,如果調(diào)出,距離今天還有多少天?
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; } }
我百度找的,不知道能不能用
開源是一種精神,但不是義務(wù),幫忙是情分,不幫也不要抱怨,建議大家多研究代碼、多閱讀代碼、多翻閱社區(qū)歷史問題!
回復(fù)迅??蚣軇?chuàng)始人
如下這樣,在show.html中可以調(diào)出相差多少天,
可是在信息循環(huán)列表中該如何調(diào)用呢
<?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; } }我百度找的,不知道能不能用
開源是一種精神,但不是義務(wù),幫忙是情分,不幫也不要抱怨,建議大家多研究代碼、多閱讀代碼、多翻閱社區(qū)歷史問題!
回復(fù)迅??蚣軇?chuàng)始人
如下這樣,在show.html中可以調(diào)出相差多少天,
可是在信息循環(huán)列表中該如何調(diào)用呢
<?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.""; ?>回復(fù)迅??蚣軇?chuàng)始人
我去,居然被我研究出來了
相差{$Days=round((strtotime(date("Y-m-d"))-strtotime($daoqiriqi))/3600/24);}天但為什么輸出的相差多少天前面會有一個-號
我去,居然最終被我搞定了
相差{$date=floor((strtotime($daoqiriqi)-strtotime(date("Y-m-d")))/86400);}天