PHP日期比较功能

What is the best way to figure out if timestamp 1263751023 was more than 60 min ago?

$time = 1263751023;
if((time() - $time) > 60 * 60)
{
   echo "Yes";
}

There are two basic way to figure this out. You can either figure out what an hour ago was and then check to see if the time you are checking was after that.

(time() - (60*60)) > $time;

The other way is you check what an hour after the time you are checking was, and see if that has passed yet.

($time + (60*60)) < time();

Oh, and the last is to check the difference between the two times, which will get you the number of seconds that have passed

(time() - $time) > (60*60)

All will get you the same answer.

One way is to calculate the difference between the one timestamp and the current timestamp:

$diff = time() - $timestamp;

And then test if that value is greater than 3600 (60 minutes with each 60 seconds):

$timestamp = 1263751023;
$diff = time() - $timestamp;
if ($diff > 3600) {
    // timestamp is more than 60 minutes ago
}
$hour = 60*60; // one hour


$time = 1263751023; // zhere you could also use time() for now

if ($time + $hour < time()) 
{
    // one hour a go
}