user4815703
user4815703

Reputation:

Check if Millis timestamp is >= 1 Hour old?

I have a Millis Timestamp which to confirm is a 13 digit bigint. I am unsure how to check if this is 1 hour old.

before i was using:

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

This is now:

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

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

i currently use:

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>';
}

but the above is not working?

Upvotes: 1

Views: 65

Answers (1)

Suchit kumar
Suchit kumar

Reputation: 11859

try using this:here $timeStamp is your timestamp value.if your $timestamp is in microtime then compare with strtotime('-1 hours')*1000.

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

Upvotes: 0

Related Questions