在php中比较两次

在php中比较两次,php,time,strtotime,Php,Time,Strtotime,可能重复: 嗨,我是php中新的时间函数,我有 @$download_time = date('d-m-Y H:i:s', $dec_time); $current_time = date('d-m-Y H:i:s'); $diff = abs(strtotime($current_time) - strtotime($download_time)); $time=65 // $time is in seconds 现在我想比较一下if($diff

可能重复:

嗨,我是php中新的时间函数,我有

@$download_time = date('d-m-Y H:i:s', $dec_time);
$current_time = date('d-m-Y H:i:s');    
$diff = abs(strtotime($current_time) - strtotime($download_time));    
$time=65 // $time is in seconds

现在我想比较一下if($diff<$time)如何与这两个值进行比较。

如果
$dec\u time
是一个unix时间戳,那么只需:

if (time() - $dec_time < $time) {/* ... */}

请确保在发布新问题之前始终尝试搜索功能。你的问题很可能以前遇到过,并且已经有了令人满意的答案。这个问题以前已经被问过几千次了。祝你好运thanx我将从下一步开始。。。
if (time() - strtotime($dec_time) < $time) {/* ... */}
if (!empty($dec_time) && time() - strtotime($dec_time) < $time) {/* ... */}