US Timezone information in Javascript

var now = new Date()
var curOffset = now.getTimezoneOffset()
curOffset /= 60 // convert from minutes to hours
var zone = ""
var prep = ""
if (curOffset == 8)
{ 
zone = "west coast"
prep = "on"
}
else
if (curOffset == 7)
{ 
zone = "mid - west"
prep = "in"
}
else
if (curOffset == 6)
{ 
zone = "mid - east"
prep = "in"
}
else
{ 
zone = "east coast"
prep = "on"
}
alert("You are in " + prep + " the " + zone + "!")

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.