Java Reference
In-Depth Information
<!DOCTYPE html>
<html lang="en">
<head>
<title>Chapter 11: Example 9</title>
</head>
<body>
<div>Local Time is <span id="spanLocalTime"></span></div>
<div id="divCityTime"></div>
<form name="form1">
<select size="5" name="lstCity">
<option value="60" selected>Berlin
<option value="330">Bombay
<option value="0">London
<option value="180">Moscow
<option value="-300">New York
<option value="60">Paris
<option value="-480">San Francisco
<option value="600">Sydney
</select>
<p>
<input type="checkbox" id="chkDst" name="chkDst" />
<label for="chkDst">Adjust city time for Daylight Savings</label>
</p>
</form>
<script>
var myForm = document.form1;
function updateTimeZone() {
var lstCity = myForm.lstCity;
var selectedOption = lstCity.options[lstCity.selectedIndex];
var offset = selectedOption.value;
var selectedCity = selectedOption.text;
var dstAdjust = 0;
if (myForm.chkDst.checked) {
dstAdjust = 60;
}
updateOutput(selectedCity, offset, dstAdjust);
}
function updateOutput(selectedCity, offset, dstAdjust) {
var now = new Date();
document.getElementById("spanLocalTime")
.innerHTML = now.toLocaleString();
now.setMinutes(now.getMinutes() + now.getTimezoneOffset() +
Search WWH ::




Custom Search