I am try to figure out how to check current time against time in database and header the user to "expired page" if the current time is greater than the one in database "1 hour"

$email = $token = $check_time = "";

$crossToken = $db->prepare("SELECT email, token, check_time FROM pw_reset_company WHERE token=? LIMIT 1");
$crossToken->bind_param('s', $c);
if ($crossToken->execute()) {
    $crossToken->bind_result($email, $token, $check_time);
    $crossToken->store_result();
    $rowCount = $crossToken->num_rows;
    if ($crossToken->fetch()) {
        $contactEmail = $email;
        $timeToExpire = $check_time;
    }
    if ($rowCount > 0) {
        date_default_timezone_set("UTC");
        $checkTime = date("H:i:s", time());
        if($timeToExpire>$checkTime){
            header("Location:?pid=expired");
        }
        ?>
        <form action="<?php $_SERVER['PHP_SELF'] ?>" method="post">
            <label for="password">Enter New Password</label>
            <input type="password" name="password" id="password">
            <label for="confirm">Enter New Password</label>
            <input type="password" name="confirm" id="confirm">
            <input type="submit" name="subNewPass" id="subNewPass" value="Reset Password">
        </form>
    <?php
    } elseif ($_GET['c'] && !(empty($_GET['c']))) {
        header("Location:?pid=expired");
    }
}

I had a same problem but i need a minutes, so you get a new time then subtract 1 hour or in my case 10 minutes from it and then you ask is that time greater then that time in database if it is you do what you want to do if not they your result from SQL will be nothing and that is it...
Code:

$newTime = date("Y-m-d H:i:s");

$timeLess10m = date("Y-m-d H:i:s", strtotime('-10 minutes', strtotime($newTime)));

$SQL="SELECT * FROM `DB` WHERE `ID` = 1 AND `TIME` < '" . $timeLess10m ."'";

$rez = mysql_query($SQL) or die("Error: ".mysql_error());
$num_rows = mysql_num_rows($rez);
if ($num_rows > 0) {
    // 10 minutes is passed
} else {
    // we are still in 10 minutes period...
}

I hope this would help, Mike.

Hi milil I edit my code to this

if ($rowCount > 0) {
        $newTime = date("Y-m-d H:i:s");
        $checkTime = date("Y-m-d H:i:s", strtotime('+1 hour', strtotime($newTime)));
        if ($dbTime < $checkTime) {
            header("Location:?pid=companyManagePasswords&mp=expire");
        }

and I think it's the same what you have provided but still no luck
any other ideas

check_time is a datetime, time, or a varchar (with timestamp) field in the database? I am asking this because in your question you seem to check from a time field but in your response you check for a date-time field. Also, in your response your $checkTime will always be 1 hour after current time. And in your if condition that header() will always be written.

If the field in the database is of datetime type, why not try this:

$currentTime = time();
$expireTime = strtotime($dbTime)+3600; // if $dbTime is datetime field in database
if ($expireTime < $currentTime) {
            header("Location:?pid=companyManagePasswords&mp=expire");
        }

Dear Adrian_5 thanks really you solved my problem it's working now fine