function hosting_format_interval in Hosting 7.4
Same name and namespace in other branches
- 5 hosting.module \hosting_format_interval()
- 6.2 hosting.inc \hosting_format_interval()
- 7.3 hosting.inc \hosting_format_interval()
Format a timestamp as a string in a friendly way.
Parameters
int $ts: The timestamp to format as a an interval.
Return value
string Returns a string representing the given timestamp:
- If the timestamp is the current time: 'Now'.
- If the timestamp is 0 or FALSE: 'Never'
- Otherwise formatted as 'X ago' where 'X' is for example 1 year or 1 minute etc.
See also
8 calls to hosting_format_interval()
- hosting_cron_node_view in cron/
hosting_cron.module - Implements hook_node_view().
- hosting_field_handler_interval::render in includes/
views/ handlers/ hosting_field_handler_interval.inc - Render the field.
- hosting_platform_view in platform/
hosting_platform.module - Implements hook_view().
- hosting_queues_configure in ./
hosting.module - Form to configure the frequency of queue execution.
- hosting_queue_summary_block in ./
hosting.module - Build a block summarising the hosting queues.
File
- ./
hosting.inc, line 74 - General purpose Hosting module functions.
Code
function hosting_format_interval($ts) {
if ($ts == REQUEST_TIME) {
return t('Now');
}
if ($ts <= 1) {
// Treats the UNIX EPOCH as never.
return t('Never');
}
return t("@interval ago", array(
"@interval" => format_interval(REQUEST_TIME - $ts, 1),
));
}