Skip to content

Instantly share code, notes, and snippets.

@manishjaingit
Forked from ManishLSN/timezonelist.php
Created December 23, 2017 09:12
Show Gist options
  • Save manishjaingit/24d66205a01a15fadabf666d273ec393 to your computer and use it in GitHub Desktop.
Save manishjaingit/24d66205a01a15fadabf666d273ec393 to your computer and use it in GitHub Desktop.
<?php
/*$date = new DateTime('2017-12-21T01:30:00.0000000', new DateTimeZone('Asia/Kolkata'));
echo "Indian time:". $date->format("Y-m-d H:i:s P");echo "<br>";
$date->setTimeZone(new DateTimeZone('America/New_York'));
echo date('Y-m-d H:i:s', strtotime('2017-12-21T01:30:00.0000000') + (5.5 * 3600));*/
/*$a = function() {
echo 'hello world';
};
var_dump($a);
$app->get('/udpateWidgetDetail', function() use($app, $serverId, $userId, $userData){
$contentDetail = $app->hubFunctions->query("select id, detail from contentlibrary where type = 30")->fetchAll(PDO::FETCH_ASSOC);
foreach($contentDetail as $value){
$detail = json_decode($value["detail"], true);
if("a" == $detail["dType"] || "v" == $detail["dType"]){
$detail["dType"] = "c";
$detail["fSize"] = 16;
}
$app->hubFunctions->update("contentlibrary", array("detail" => json_encode($detail)), array("id" => $value["id"]));
}
$app->hubFunctions->echoResponse(array("desc" => "type = static has been updated", "status" => "success"));
});*/
/*var_dump(DateTimeZone::listIdentifiers());die;
//var_dump(DateTimeZone::listIdentifiers(DateTimeZone::ALL));
var_dump(DateTimeZone::listAbbreviations());*/
function tz_list() {
$zones_array = array();
$timestamp = time();
foreach(timezone_identifiers_list() as $key => $zone) {
date_default_timezone_set($zone);
$zones_array[$key]['zone'] = $zone;
$zones_array[$key]['diff_from_GMT'] = 'UTC/GMT ' . date('P', $timestamp);
}
return $zones_array;
}
//echo "<pre>";
//$n = tz_list();
//var_dump(date_default_timezone_set("Africa/Accra"));
//var_dump($n);
?>
<div style="margin-top: 20px;">
<select style="font-family: 'Courier New', Courier, monospace; width: 450px;">
<option value="0">Please, select timezone</option>
<?php foreach(tz_list() as $t) { ?>
<option value="<?php print $t['zone'] ?>">
<?php print $t['diff_from_GMT'] . ' - ' . $t['zone'] ?>
</option>
<?php } ?>
</select>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment