Mark Topper Mark Topper - 1 year ago 122
PHP Question

Timestamp check if older than 12 hours

How can I check if a timestamp is older than 12 hours?

I need to make a link work for 12 hours, after that I need to display an error message.

Answer Source
$dateFromDatabase = strtotime("2012-12-04 12:05:04");
$dateTwelveHoursAgo = strtotime("-12 hours");

if ($dateFromDatabase >= $dateTwelveHoursAgo) {
    // less than 12 hours ago
else {
    // more than 12 hours ago
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download