I have seen this which gets date of a one time zone from another time zone but what I want is to find out which timezone the user is in and then get date accordingly.
My website is current using this script to count the time till new year. I just realized that if the user is on a different time zone the timer will not be correct. So how do I find the time difference between the present date and new year depending on the users location.
var daysSpan = document.getElementById("days");
var hoursSpan = document.getElementById("hours");
var minutesSpan = document.getElementById("minutes");
var secondsSpan = document.getElementById("seconds");
var c=1;
function updateClock(){
var t = Date.parse('January 1 2016 00:01:05') - Date.parse(new Date());
if (t<=0 && c==1)
{
c--;
window.open("http://www.its2016.weebly.com","_self");
}
var seconds = Math.floor( (t/1000) % 60 );
var minutes = Math.floor( (t/1000/60) % 60 );
var hours = Math.floor( (t/(1000*60*60)) % 24 );
var days = Math.floor( t/(1000*60*60*24) );
daysSpan.innerHTML = days;
hoursSpan.innerHTML = hours;
minutesSpan.innerHTML = minutes;
secondsSpan.innerHTML = seconds;
}
setInterval(updateClock,1000);