Skip to content
Advertisement

How can I check if the time is more than an hour later?

So I have a database entry that update the date/time in yyyy-mm-dd hh:mm:ss.

Now I want to check, if there is a space inbetween the the database and the actual time from 60 minutes. How can I do that?

Example:

DB: 2020-02-14 10:00:00
Time now: 2020-02-14 11:01:00
Do something

DB: 2020-02-14 10:00:00
Time now: 2020-02-14 10:59:00
Do nothing

Advertisement

Answer

You can use something like this:

$t1 = strtotime( '2006-04-14 11:30:00' );
$t2 = strtotime( '2006-04-12 12:30:00' );
$diff = round(($t1 - $t2) / 3600);
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement