// intval() - http://php.net/manual/en/function.intval.php $seconds_ago = (time() - strtotime('2014-01-06 15:25:08')); if ($seconds_ago >= 31536000) { echo "Seen " . intval($seconds_ago / 31536000) . " years ago"; } elseif ($seconds_ago >= 2419200) { echo "Seen " . intval($seconds_ago / 2419200) . " months ago"; } elseif ($seconds_ago >= 86400) { echo "Seen " . intval($seconds_ago / 86400) . " days ago"; } elseif ($seconds_ago >= 3600) { echo "Seen " . intval($seconds_ago / 3600) . " hours ago"; } elseif ($seconds_ago >= 60) { echo "Seen " . intval($seconds_ago / 60) . " minutes ago"; } else { echo "Seen less than a minute ago"; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter