function facetapi_format_timestamp in Facet API 7
Same name and namespace in other branches
- 6.3 facetapi.date.inc \facetapi_format_timestamp()
- 7.2 facetapi.date.inc \facetapi_format_timestamp()
Returns a formatted date based on the passed timestamp and gap.
This function assumes that gaps less than one day will be displayed in a search context in which a larger containing gap including a day is already displayed. So, HOUR, MINUTE, and SECOND gaps only display time information, without date.
Parameters
$timestamp: An integer containing the Unix timestamp.
$gap: A string containing the gap, see FACETAPI_DATE_* constants for valid values, defaults to YEAR.
Return value
A gap-appropriate display date used in the facet link.
1 string reference to 'facetapi_format_timestamp'
- facetapi_map_date in ./
facetapi.callbacks.inc - Maps date ranges to human readable dates.
File
- ./
facetapi.date.inc, line 191 - Date handling functions.
Code
function facetapi_format_timestamp($timestamp, $gap = FACETAPI_DATE_YEAR) {
switch ($gap) {
case FACETAPI_DATE_MONTH:
return format_date($timestamp, 'custom', 'F Y', 'UTC');
case FACETAPI_DATE_DAY:
return format_date($timestamp, 'custom', 'F j, Y', 'UTC');
case FACETAPI_DATE_HOUR:
return format_date($timestamp, 'custom', 'g A', 'UTC');
case FACETAPI_DATE_MINUTE:
return format_date($timestamp, 'custom', 'g:i A', 'UTC');
case FACETAPI_DATE_SECOND:
return format_date($timestamp, 'custom', 'g:i:s A', 'UTC');
default:
return format_date($timestamp, 'custom', 'Y', 'UTC');
}
}