function partial_date_generate_date in Partial Date 7
This generates a date component based on the specified timestamp and timezone. This is used for deminstrational purposes only, and may fall back to the request timestamp and site timezone.
This could throw errors if outside PHP's native date range.
1 call to partial_date_generate_date()
File
- ./
partial_date.admin.inc, line 1070 - Less freq. functions for field administration.
Code
function partial_date_generate_date($timestamp = REQUEST_TIME, $timezone = NULL) {
// PHP Date should handle any integer, but outside of the int range, 0 is
// returned by intval(). On 32 bit systems this is Fri, 13 Dec 1901 20:45:54
// and Tue, 19 Jan 2038 03:14:07 GMT
$timestamp = intval($timestamp);
if (!$timestamp) {
$timestamp = REQUEST_TIME;
}
if (!$timezone) {
//$timezones = partial_date_granularity_field_options('timezone');
//$timezone = $timezones[rand(0, count($timezones) - 1)];
$timezone = partial_date_timezone_handling_correlation('UTC', 'site');
}
try {
$tz = new DateTimeZone($timezone);
$date = new DateTime('@' . $timestamp, $tz);
if ($date) {
return array(
'year' => $date
->format('Y'),
'month' => $date
->format('n'),
'day' => $date
->format('j'),
'hour' => $date
->format('G'),
'minute' => $date
->format('i'),
'second' => $date
->format('s'),
'timezone' => $timezone,
);
}
} catch (Exception $e) {
}
return FALSE;
}