-2

Possible Duplicate:
PHP Timestamp until “hours ago” trouble

How can I make a PHP timestamp that will display the time ago until hours only? for example displaying 48hours instead of 2days ago and 480hours instead of 20days ago.

Community
  • 1
  • 1

1 Answers1

1
$dateposted = '2012-12-1 12:59:44';
$dateposted2 = '1354661156'; // time();

echo ceil((strtotime("now") - strtotime($dateposted))/3600);
echo ceil((strtotime("now") - $dateposted2)/3600);
mychalvlcek
  • 3,956
  • 1
  • 19
  • 34