function lingotek_human_readable_timestamp in Lingotek Translation 7.6
Same name and namespace in other branches
- 7.7 lingotek.util.inc \lingotek_human_readable_timestamp()
- 7.4 lingotek.util.inc \lingotek_human_readable_timestamp()
- 7.5 lingotek.util.inc \lingotek_human_readable_timestamp()
3 calls to lingotek_human_readable_timestamp()
- lingotek_bulk_grid_form in ./
lingotek.bulk_grid.inc - lingotek_bulk_grid_parse_table_data in ./
lingotek.bulk_grid.inc - lingotek_push_form in ./
lingotek.page.inc - Upload Content Form. (Upload to Lingotek)
File
- ./
lingotek.util.inc, line 968 - Utility functions.
Code
function lingotek_human_readable_timestamp($unix_timestamp, $as_array = FALSE) {
$time = time() - $unix_timestamp;
$intervals = array(
31536000 => t('year'),
2592000 => t('month'),
604800 => t('week'),
86400 => t('day'),
3600 => t('hour'),
60 => t('minute'),
1 => t('second'),
);
foreach ($intervals as $unit => $text) {
if ($time < $unit) {
continue;
}
$number = floor($time / $unit);
if ($as_array) {
return array(
'number' => $number,
'interval' => $text . ($number > 1 ? 's' : ''),
);
}
else {
return $number . ' ' . $text . ($number > 1 ? 's' : '');
}
}
if ($as_array) {
return array(
'number' => 0,
'interval' => t('seconds'),
);
}
else {
return '0 ' . t('seconds');
}
}