Window.onload = function () { TODO begin processing Login user Time zone Get the difference between the login user time zone and GMT time zone var exp = new Date (); var gmthours =-(Exp.gettimezoneoffset ()/60); Setcookie (' Customer_timezone ', gmthours,1); Determine if daylight saving time is Date = Exp.format (' yyyy-mm-dd HH:mm:ss '); if (indaylighttime (date)) { Setcookie (' Indaylighttime ', 1, 1); } } Set cookies function Setcookie (c_name,value,expiredays) { var exdate=new Date () Exdate.setdate (Exdate.getdate () +expiredays) document.cookie=c_name+ "=" +escape (value) + ((expiredays==null)? "" : "; Expires= "+exdate.togmtstring ()) } Judging whether the time is the old or the Western Hemisphere function Iseastearthtime (newdate) { var dj= newdate.getgmtoffset (false); if (Dj.indexof ("-") = =-1) { return true; } else { return false; } } Whether it is daylight saving time function Indaylighttime (date) { var start = new Date (Date.gettime ()); Start.setmonth (0); Start.setdate (1); Start.sethours (0); Start.setminutes (0); Start.setseconds (0); var middle = new Date (Start.gettime ()); Middle.setmonth (6); If the year starts and the middle time difference is the same, it is considered that the country does not have daylight if ((Middle.gettimezoneoffset ()-start.gettimezoneoffset ()) = = 0) { return false; } var margin = 0; if (this.iseastearthtime (date)) { margin = Middle.gettimezoneoffset (); } else { margin = Start.gettimezoneoffset (); } if (date.gettimezoneoffset () = = margin) { return true; } return false; } Done End |