use*_*748 0 php string date strtotime
检查给定日期的最佳方法是什么 - 字符串d/mm/yyyy是过去的?当我使用strtotime()时,由于非美国符号,它不能很好地工作.当然,我可能会将日期作为字符串处理并比较子字符串,但必须有更好的方法.
if((strtotime('now')-strtotime($date)) > 86400) echo $date;
Run Code Online (Sandbox Code Playgroud)
strtotime('now')是一个可怕的滥用功能.您应该只使用time()获得EXACT SAME结果而没有任何strtotime开销.
$thatTime = date_create_from_format('d/m/Y', $date)->getTimestamp();
if (time() - $thatTime > 86400) echo $date;
Run Code Online (Sandbox Code Playgroud)
date_create_from_format()的相关文档