Js Date time stamp issues and other district summary

js the Date stamp printing zone concept is sometimes no new Date (1) at any time is a relative time zone as shown below:

var t = new Date(1);
t // Thu Jan 01 1970 08:00:00 GMT + 0800 ( China Standard Time) 
// change the computer's time zone UTC + 02: 00 time zone in Damascus is also performed in the console
var k = new Date(1); k // Thu Jan 01 1970 02:00:00 GMT + 0200 (Eastern European Standard Time)

  

In doing so we often project will be local time zone conversion time is zero, if the time string takes time difference between a time zone; but if the time stamp, the time string directly into the new Date () on it; the same if the passed time stamps do not need to think any display local time conversion

// string passed in time is converted to local time zone timestamp 0:00 zones (part time stamp is the same time zone which time zones) 
function covertUTCnTo0Time(str){
    return new Date(str).getTime()
}
// string passed time 0:00 local time zone string through conversion new Date (). GetTime () is converted to a stamp, there is no need to manually increase or decrease in the time zone of the   
 function covert0TimeToUTC(str){
     var stamp = new Date(str).getTime()
     return dateFormat(new Date(stamp),'yyyy-MM-dd hh:mm:ss')
 }
// dateFormat conversion function to write their own time

  

Otherwise there will be a time when the gap area

Guess you like

Origin www.cnblogs.com/xhliang/p/11888326.html