Mic*_*zek 14
您可以使用strtotime将字符串转换为UNIX时间戳,以秒为单位.time()将为您提供当前的UNIX时间戳.减去它们以获得日期的秒数,然后除以60*60*24以天为单位得到它
虽然我发现日期函数比使用类更容易,但它也可以使用DateTime :: diff
小智 10
$today = strtotime(date('Y-m-d H:i:s'));
$expireDay = strtotime($row['ExpireDate']);
$timeToEnd = $expireDay - $today;
Run Code Online (Sandbox Code Playgroud)