-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmytimezone.php
executable file
·35 lines (32 loc) · 971 Bytes
/
mytimezone.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
if (isset($_GET['offset'])) {
echo 'Your current timezone is ' . timezone_name_from_abbr('', $_GET['offset'] * 60, false);
exit;
}
?>
<html>
<head>
<title>MY TIMEZONE</title>
</head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
var timezone_offset_minutes = new Date().getTimezoneOffset();
timezone_offset_minutes = timezone_offset_minutes === 0 ? 0 : -timezone_offset_minutes;
$.ajax({
type: 'GET',
url: window.location.href + '?offset=' + timezone_offset_minutes,
success: function (response) {
$('#timezone').html(response);
},
error: function (e) {
alert('fail');
console.log(e.responseText);
}
});
});
</script>
<body>
<div id="timezone"></div>
</body>
</html>