TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Abc Thakur
NA
298
9.4k
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
Reply
Answers (
4
)
values should be in same line
Get latitude and longitude from Zipcode