Update to the clock.
Now allowing for display of the time in the original timezone as well as the user selected one. I've also added a rule to the CSS file to better display the selection list on mobile screens.
This commit is contained in:
19
clock.php
19
clock.php
@@ -9,6 +9,7 @@
|
||||
if(!isset($selectedTimezone)){
|
||||
//I don't have any error message set here. It will just reload the page.
|
||||
} else{
|
||||
$originalTZ = date_default_timezone_get();
|
||||
date_default_timezone_set($selectedTimezone);
|
||||
$scriptTZ = date_default_timezone_get();
|
||||
}
|
||||
@@ -29,7 +30,7 @@
|
||||
<meta name="author" content="efrick"/>
|
||||
<link href="/styles.css" type="text/css" rel="stylesheet"/>
|
||||
<link href="clock.css" type="text/css" rel="stylesheet"/>
|
||||
<script>var current_tz=<?php echo json_encode($scriptTZ);?></script>
|
||||
<script>var current_tz=<?php echo json_encode($scriptTZ) . ',original_tz = ' . json_encode($originalTZ);?></script>
|
||||
<script type="text/javascript" src="clock.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
@@ -43,7 +44,15 @@
|
||||
"<p id='time_body'>".
|
||||
date("D, M d, Y, H:i:s") .
|
||||
"</p><p> GMT". date("O T") ."</p>\n\t\t</span>";
|
||||
?>
|
||||
if($_POST['originalTZ']){// if the user want display the browser detected timezone as well as the selected one.
|
||||
date_default_timezone_set($originalTZ);
|
||||
echo'<h3>Time in original Timezone</h3>'.
|
||||
'<span><p id="time_original">'.
|
||||
date("D, M d, Y, H:i:s") .
|
||||
"</p><p> GMT". date("O T") .'</p></span>';
|
||||
date_default_timezone_set($scriptTZ);
|
||||
}
|
||||
?>
|
||||
<div class="tz_select">
|
||||
<p>
|
||||
If the detcted timezone is not correct selct your timezone from the dropdown below.
|
||||
@@ -90,10 +99,12 @@
|
||||
<option value="Asia/Magadan" >(GMT +11:00) Magadan, Solomon Islands, New Caledonia</option>
|
||||
<option value="Asia/Kamchatka" >(GMT +12:00) Auckland, Wellington, Fiji, Kamchatka</option>
|
||||
</select>
|
||||
|
||||
<input type="submit" name="formSubmit" value="Update" >
|
||||
<br/>
|
||||
<label for="originalTZ">Display original timezone</label>
|
||||
<input type="checkbox" name="originalTZ" value="origTZ">
|
||||
</form>
|
||||
<p id="JStz">JS Timezone</p>
|
||||
<p id="JStz"><?php echo date("e");?></p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user