Abc Thakur

Abc Thakur

  • NA
  • 298
  • 9.3k

Timezone option values

Feb 9 2015 5:18 AM
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();
}
Html:
<select name="timezone" onchange="calcTime(this.value)" >
<option selected>Select Time Zone</option>
<option value="-8">Pacific Standard Time (PST)</option>
<option value="-7" > Mountain Standard Time (MST)</option>
<option value="-6" >Central Standard Time (CST)</option>
<option value="-5"  >Eastern Standard Time (EST)</option>
</select>
 
<input type="text"  id="result"> 
This works on value change... but i want to save value as
<select name="timezone" onchange="calcTime(this.value)" >
<option selected>Select Time Zone</option>
<option value="PST">Pacific Standard Time (PST)</option>
<option value="MST" > Mountain Standard Time (MST)</option>
<option value="CST" >Central Standard Time (CST)</option>
<option value="EST" >Eastern Standard Time (EST)</option>
</select>
 
 but the it is not working if i write PST etc.. What can i do??
Please help 
 

Answers (4)