Create Day, Hour, Minute and Second countdown in PHP

前端 未结 3 1651
無奈伤痛
無奈伤痛 2021-01-26 03:47

So far I\'ve got this script that counts down the days and hours, but how can I make it also do minutes and seconds?

$remaining = strtotime($ActiveListing[\'Lis         


        
3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-26 04:25

    I thought of a solution with date():

    $remaining = strtotime($ActiveListing['ListingExpires']) - time();
    list($months, $days, $hours, $minutes, $seconds) = explode(" ",date("n j H i s",$remaining));
    $months--;$days--;
    echo "$months months - $days days - $hours hours - $minutes minutes - $seconds seconds left";
    

提交回复
热议问题