Created
March 26, 2010 18:39
-
-
Save jeremeamia/345227 to your computer and use it in GitHub Desktop.
Find approximate time passed - Ko3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // Uses Kohana 3 Framework | |
function time_ago($timestamp) | |
{ | |
$time_ago = Date::span($timestamp); | |
foreach ($time_ago as $unit => $value) | |
{ | |
if ($value > 0) | |
{ | |
return 'about '.$value.' '.Inflector::singular($unit, $value).' ago'; | |
} | |
} | |
return 'just now'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment