forked from andrew867/timeclock
-
Notifications
You must be signed in to change notification settings - Fork 1
/
tzoffset.php
30 lines (23 loc) · 1013 Bytes
/
tzoffset.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
<script language="JavaScript">
var time = new Date()
var cookieexpire = new Date(time.getTime() + 90 * 24 * 60 * 60 * 1000); //cookie expires in 90 days
var timeclock = document.cookie;
var timezone = (-(time.getTimezoneOffset()))
function getthecookie(name) {
var index = timeclock.indexOf(name + "=");
if (index == -1) return null;
index = timeclock.indexOf("=", index) + 1;
var endstr = timeclock.indexOf(";", index);
if (endstr == -1) endstr = timeclock.length;
return unescape(timeclock.substring(index, endstr));
}
function setthecookie(timeclock, value) {
if (value != null && value != "")
document.cookie = timeclock + "=" + escape(value) + "; expires=" + cookieexpire.toGMTString();
timeclock = document.cookie;
}
var tzoffset = getthecookie("tzoffset") || timezone;
if (tzoffset == null || tzoffset == "")
tzoffset = "0";
setthecookie("tzoffset", tzoffset);
</script>