human_time_diff [ WordPress Function ]
human_time_diff ( $from, $to = '' )
| Parameters: |
|
| Returns: |
|
| Defined at: |
|
Determines the difference between two timestamps.
The difference is returned in a human readable format such as "1 hour", "5 mins", "2 days".
Source
<?php
function human_time_diff( $from, $to = '' ) {
if ( empty($to) )
$to = time();
$diff = (int) abs($to - $from);
if ($diff <= 3600) {
$mins = round($diff / 60);
if ($mins <= 1) {
$mins = 1;
}
/* translators: min=minute */
$since = sprintf(_n('%s min', '%s mins', $mins), $mins);
} else if (($diff <= 86400) && ($diff > 3600)) {
$hours = round($diff / 3600);
if ($hours <= 1) {
$hours = 1;
}
$since = sprintf(_n('%s hour', '%s hours', $hours), $hours);
} elseif ($diff >= 86400) {
$days = round($diff / 86400);
if ($days <= 1) {
$days = 1;
}
$since = sprintf(_n('%s day', '%s days', $days), $days);
}
return $since;
}
?>
Examples [ wp-snippets.com ]
Google Arama Sonuçlarý
- Function Reference/human time diff « WordPress Codex
Description. Determines the difference between two timestamps. The difference is returned in a human readable format such as "1 hour", "5 mins", "2 days".
codex.wordpress.org - WordPress › Support » [Plugin: Timeago] human_time_diff()
As I mentioned in my post at WPSplash, there are few reasons I chose jQuery timeago plugin and modified the wordpress date/time to use relative time based on ...
wordpress.org - Jason Bobich | human_time_diff
You may have noticed the cool little featured here on my personal blog where, instead of showing the date of the current WordPress post in the typical format, I' m ...
www.jasonbobich.com - human_time_diff - UpThemes
Tag Archives: human_time_diff. Mar 242010 · human_time_diff, time ago. human_time_diff. WordPress Master Tip: Display "Time Ago" for Posts or Comments ...
upthemes.com