Search code examples
phpdatedatetimeunix-timestamp

PHP Get hour difference in datetime


so I have these two time stamps in PHP

1253339331
1253338959

I want to be able to somehow get the hour difference between those to datetimes. Our users should only have 24 hours to login after their first attempt, so I need to find out if it's less than 24 hours to allow them to login again.


Solution

  • if ((t2-t1)/3600) < 24 { ... }