function facetapi_isodate in Facet API 7.2
Same name and namespace in other branches
- 6.3 facetapi.date.inc \facetapi_isodate()
- 6 facetapi.module \facetapi_isodate()
- 7 facetapi.date.inc \facetapi_isodate()
Helper function to convert dates from Unix timestamps into ISO 8601 format.
Parameters
$timestamp: An integer containing the Unix timestamp being converted.
$gap: A string containing the gap, see FACETAPI_DATE_* constants for valid values. Defaults to FACETAPI_DATE_SECOND.
Return value
A string containing the date in ISO 8601 format.
1 call to facetapi_isodate()
- facetapi_get_next_date_increment in ./
facetapi.date.inc - Returns the next increment from the given ISO date and gap. This function is useful for getting the upper limit of a date range from the given start date.
File
- ./
facetapi.date.inc, line 20 - Date handling functions.
Code
function facetapi_isodate($timestamp, $gap = FACETAPI_DATE_SECOND) {
switch ($gap) {
case FACETAPI_DATE_SECOND:
$format = FACETAPI_DATE_ISO8601;
break;
case FACETAPI_DATE_MINUTE:
$format = 'Y-m-d\\TH:i:00\\Z';
break;
case FACETAPI_DATE_HOUR:
$format = 'Y-m-d\\TH:00:00\\Z';
break;
case FACETAPI_DATE_DAY:
$format = 'Y-m-d\\T00:00:00\\Z';
break;
case FACETAPI_DATE_MONTH:
$format = 'Y-m-01\\T00:00:00\\Z';
break;
case FACETAPI_DATE_YEAR:
$format = 'Y-01-01\\T00:00:00\\Z';
break;
default:
$format = FACETAPI_DATE_ISO8601;
break;
}
return gmdate($format, $timestamp);
}