[Solved] how can i make a countdown timer that goes past the 60minutes


The current minute is never an issue. You are concerned with the duration since last blocked, not with “what time was that”:

block_user.php:

<?php
$now = new DateTime();
write_block_into_database($ip_address, $now->format('Y-m-d H:i:s'));
?>

check_block.php

<?php
$sql="SELECT 1 FROM sometable WHERE ip_address=? AND DATE_ADD(blocked_at, INTERVAL 1 HOURS) >= NOW()";
if(get_result($sql, $ip_address)) { 
   // this address is blocked
} else {
   // no recent block found
}

Or, if you want to do the comparison in PHP:

check_locally.php:

<?php
$sql = "SELECT blocked_at FROM sometable WHERE ip_address=?";
$db_row = get_row($sql,$ip_address);
if ($db_row) {
    $blocked = new DateTime($db_row->blocked_at);
    $blocked->modify('+1 hour');
    $now = new DateTime();

    if ($blocked >= $now) {
       // still blocked
    } else {
       // was blocked earlier, no more
    }
} else {
    // not blocked
}

In other words: “if I take the time the IP was blocked and add one hour, is now still before that point in time?”

Example:

  • blocked at 12:48
  • checking at 13:10: 12:48 + 1 hour = 13:48, 13:48 >= 13:10, fail
  • checking at 15:10: 12:48 + 1 hour = 13:48, 13:48 < 15:10, pass

1

solved how can i make a countdown timer that goes past the 60minutes