×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Javascript
Posted by: Vlad Krasovsky
Added: Oct 16, 2014 6:18 PM
Views: 10
Tags: no tags
  1. timeConverter = new Object();
  2.  
  3. timeConverter.loadTimeZone = function(obj){
  4.     var timeZone = fuzzUtils.getCookie('client-timezone-offset');
  5.     if(timeZone == false){
  6.         timeConverter.setTimeZone();
  7.     }
  8.    
  9. }
  10.  
  11. timeConverter.dateTime = function(offset){
  12.      tDate = new Date();
  13.    
  14.     // convert to msec
  15.     // add local time zone offset
  16.     utc = tDate.getTime() + (tDate.getTimezoneOffset() * 60000);
  17.    
  18.     // using supplied offset
  19.     nd = new Date(utc + (3600000*offset));
  20.    
  21.     return nd;
  22. }
  23.  
  24.  
  25. timeConverter.setTimeZone = function(obj){
  26.     var d = new Date();
  27.     var offset = -(d.getTimezoneOffset())/60;
  28.  
  29.     timeConverter.setCookie('client-timezone-offset',offset,30);
  30.     //refresh page;
  31.     location.reload();
  32.  
  33. }
  34.  
  35. timeConverter.setCookie = function(name,value,exdays){
  36.     var d = new Date();
  37.     d.setTime(d.getTime() + (exdays*24*60*60*1000));
  38.     var expires = "expires="+d.toUTCString();
  39.     document.cookie = name + "=" + value + "; " + expires + ";domain=.cityvibe.com;path =/";
  40. }
  41.  
  42. // call the init method
  43. $(document).ready(function(){timeConverter.loadTimeZone();});