Print the time an hour ago

TheBlackBenzKid picture TheBlackBenzKid · Feb 20, 2012 · Viewed 51.5k times · Source

Possible Duplicate:
Given a time, how can I find the time one month ago

How can I print an hour ago in PHP using Date?

$date=date("Y-m-d H:i:s");
$time(-1, now);
$result=$date.$time;

So If I wanted to say "John visited last "

Would print

John visited last 20th Feb 2012, 17.26

Answer

Paul picture Paul · Feb 20, 2012
$date = date('Y-m-d H:i:s', strtotime('-1 hour'));
echo 'John visited last ' . $date;