<script>
function displayTime(){
var h = new Date().getHours();
var m = new Date().getMinutes()
var s = new Date().getSeconds()
var ha = h * (360/12) + (m*.5);
var ma = m * (360/60)
var sa = s * (360/60);
document.getElementById("sec").style.transform =
'translate(150px) rotate(' + sa + 'deg)'
document.getElementById("min").style.transform =
'translate(150px,20px) rotate(' + ma + 'deg)'
document.getElementById("hour").style.transform =
'translate(150px,50px) rotate(' + ha + 'deg)'
}
function start(){
displayTime();
setInterval("displayTime()", 1000);
}
</script>
</head>
<body onload='start()'>
<select name="DropDownTimezone" id="DropDownTimezone">
<option value="default">You are here</option>
<option value="-12.0">(GMT -12:00) Eniwetok,
Kwajalein</option>
<option value="-11.0">(GMT -11:00) Midway Island,
Samoa</option>
<option value="-10.0">(GMT -10:00)
Hawaii</option>
<option value="-9.0">(GMT -9:00) Alaska</option>
</select>
I have this html and java script code. This webpage gives user to select different timezone and displays that time in a analog clock. I just want to know how to use getTimezoneOffset() to make this dropdown menu functional. I would really appreciate if someone could help me. Thank you.
The client’s timezone offset could be detected by using the Date object’s getTimezoneOffset() method.
The getTimezoneOffset() method returns the time difference between UTC time and local time, that is the time offset, in minutes. This offset is changed by dividing by 60 and negating the result.
below function will return the getTimeZone()
<input type="text" name="result" id="result" value="">
<select name="timezone" onChange="calcTime(this.value)">
<script language="JavaScript">
function calcTime(offset)
{
d = new Date();
utc = d.getTime() + (d.getTimezoneOffset() * 60000);
nd = new Date(utc + (3600000*offset));
document.getElementById('result').value=nd.toLocaleString();
}
</script>
<script> function displayTime(){ var h = new Date().getHours(); var m = new Date().getMinutes() var s =...
Form Processing HTML
One of the most ubiquitous uses of JavaScript is validating form
data on the client side before it is submitted to the server. It is
done everywhere because it is fast and it gives you a great deal of
flexibility in how you handle errors insofar as the GUI is
concerned.
Attached is an image of some code I wrote (so Blackboard can't
mess it up). Some things to notice that will help you with the
lab....