检查Millis时间戳是否> = 1小时?

时间:2015-11-01 04:54:09

标签: php

我有一个Millis时间戳确认是13位bigint。我不确定如何检查这是否是1小时。

在我使用之前

time() with strtotime('-1 hour'); I dont think this will work now.

现在是:

$timestamp = round(microtime(true) * 1000) << returns Current Timestamp.

if($timestamp >= 1 hour ago):
    do something
else:
    do something
endif;

我目前使用:

if($timestamp >= strtotime('-1 hour')) {
    echo '<button class="btn btn-sm btn-warning btn-refresh" disabled=disabled name="refresh-history">Updated!</button>';
} else {
    echo '<form action="/actions.php" method="post"><input type="hidden" name="id" value='.$order_id.'><button class="btn btn-sm btn-warning btn-refresh" name="refresh-history">Update Now!</button></form>';
}

但上述不起作用?

1 个答案:

答案 0 :(得分:1)

尝试使用此功能:此处$timeStamp是您的时间戳值。如果$timestamp位于microtime,则与strtotime('-1 hours')*1000进行比较。

if ($timeStamp <= strtotime('-1 hours')) {
    echo "one or more hour old";
} else {
    echo "not";
}
相关问题