function timeago_time_zones in Timeago 7.2
Generate an array of time zones and their local time & date.
This function is identical to system_time_zones() except that it allows specifying a custom date format for the local time and date. This difference allows using formats other than the default Long date format, which is important when a Timeago format is the default since that would include hard-to-read escaped HTML markup.
Parameters
$blank: (Optional) If evaluates true, prepend an empty time zone option to the array.
$date_format: (Optional) The format of the human-readable date values.
Return value
An associative array of time zones. Keys are zone IDs and values are the current local datetime + UTC offset.
See also
1 call to timeago_time_zones()
- timeago_form_user_profile_form_alter in ./
timeago.module - Implements hook_form_FORM_ID_alter().
File
- ./
timeago.module, line 456 - Adds support for the Timeago jQuery library.
Code
function timeago_time_zones($blank = NULL, $date_format = '') {
$zonelist = timezone_identifiers_list();
$zones = $blank ? array(
'' => t('- None selected -'),
) : array();
foreach ($zonelist as $zone) {
// Because many time zones exist in PHP only for backward compatibility
// reasons and should not be used, the list is filtered by a regular
// expression.
if (preg_match('!^((Africa|America|Antarctica|Arctic|Asia|Atlantic|Australia|Europe|Indian|Pacific)/|UTC$)!', $zone)) {
$zones[$zone] = t('@zone: @date', array(
'@zone' => t(str_replace('_', ' ', $zone)),
'@date' => format_date(REQUEST_TIME, 'custom', $date_format . ' O', $zone),
));
}
}
// Sort the translated time zones alphabetically.
asort($zones);
return $zones;
}