title: How to set javascript global timezone
body: <p>My current timezone is in IST and I want it dynamic for example if I set my timezone to PST in my database then I need to set it to javascript and whenever I try to create date object it should return time in PST.</p>
  
  <p>Without wasting much time in it I want to know is it possible or not if yes any possible way ?</p>
  
  <p>I have this function anyways in <code>time_zone_offset</code> its returning time 5 hours ago than UTC and my system timezone is +5.5 than UTC <code>date</code> is just 2 mins. ago but its returning 10 hours ago</p>
  
  <pre><code>var currentDate = new Date(new Date().getTime()); // local system date
                  var timezoneOffset = time_zone_offset;
  
                  //Convert current dateTime into UTC dateTime
                  var utcDate = new Date(currentDate.getTime() + (timezoneOffset * 60000));
                  //console.log(utcDate);               
  
                  //Convert date string (2015-02-02 07:12:13) in date object
                  var t = date.split(/[- :]/);
                  var today = new Date();
                  // Apply each element to the Date function
                  var date = new Date(t[0], t[1]-1, t[2], t[3], t[4], t[5]);
                  //date = new Date(date);
                  var dateDiff        = Math.floor((utcDate.getTime()/1000)) - Math.floor((date.getTime()/1000));                  
                  var formatedDate    = '';
                  var time            = '';
                  var fullDays        = Math.floor(dateDiff/(60*60*24));
                  var fullHours       = Math.floor((dateDiff-(fullDays*60*60*24))/(60*60));
                  var fullMinutes     = Math.floor((dateDiff-(fullDays*60*60*24)-(fullHours*60*60))/60);
                  var fullSeconds     = Math.floor((dateDiff-(fullDays*60*60*24)-(fullHours*60*60)-(fullMinutes*60)));
                  var dayArray        = new Array('Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday');
                  var monthArray      = new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Nov','Dec');
                  //console.log(dateDiff);
  
                  date = new Date(date.getTime() - (timezoneOffset * 60000));
  
                  if(fullDays &gt; 2){
                      //var dt = new Date(date*1000);
                      time = monthArray[date.getMonth()]+' '+date.getDate()+' at '+formatAMPM(date);
                  } else if(fullDays == 2){
                      time = '2 days';
                  } else if(today.getDate() &gt; t[2]){
                      time = 'Yesterday at '+formatAMPM(date);
                  } else if(fullHours &gt; 0) {
                      time = fullHours + ' hours';
                      if(fullHours == 1) {
                          time = fullHours + ' hour';
                      }
                  } else if(fullMinutes &gt; 0) {
                      time = fullMinutes + ' mins';
                      if (fullMinutes == 1) {
                          time = fullMinutes + ' min';
                      }
                  } else {
                      time = 'Just now';
                  }
                  return time;
  </code></pre>