$time = time() - strtotime($created_at); // $created_at is a string of time i.e. Fri Mar 18 17:24:35 PDT 2011
$days = floor($time/24/60/60);
if ($days > 0) {
$days_out = "$days day";
$days_out .= $days > 1 ? 's' : '' .", ";
}
$hours = floor(($time % (24*60*60))/60/60);
$hours_out = "{$hours} hour";
$hours_out .= $hours > 1 ? 's' : '' . " ago";
echo "{$days_out}{$hours_out}";
My passion has always been on software development, and I know it since I
wrote my first program on an Apple II. I worked on cellular wireless system
in the past (C/C++) and now focus on web application
(LAMP, PHP, MySQL, CakePHP, Symfony, jQuery, Google AppEngine/python).
![[Valid XHTML 1.0 Strict]](https://edmondhui.ddns.net/blog/skins/admun3/valid-xhtml.png)