Skip to content

Instantly share code, notes, and snippets.

@dannetstudio
Created October 6, 2022 17:46
Show Gist options
  • Save dannetstudio/24d9d3aba65a01886a59498dd5ed16bb to your computer and use it in GitHub Desktop.
Save dannetstudio/24d9d3aba65a01886a59498dd5ed16bb to your computer and use it in GitHub Desktop.
getTimeZoneList Helper
<?php
static public function getTimeZoneList()
{
return \Cache::rememberForever('timezones_list_collection', function () {
$timestamp = time();
foreach (timezone_identifiers_list(\DateTimeZone::ALL) as $key => $value) {
date_default_timezone_set($value);
$timezone[$value] = $value . ' (UTC ' . date('P', $timestamp) . ')';
}
return collect($timezone)->sortKeys();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment