js the conversion time timestamp
How specific timestamp defined I do not know, but Baidu Encyclopedia there are such a sentence: "timestamp is from January 1, 1970 (00:00:00 GMT) time to the current total number of seconds."
According to this definition, the programming language does have a similar function, getTime (), but this function returns January 1 to the current time of the total number of milliseconds since 1970 instead of the total number of seconds.
In the js, converted to a character type is not a difficult Date:
var STR = '2013-08-30'; // date string
str = str.replace (// g, ' /'); // the - replace /, because only supports the following constructors / date string delimited
var date = new date (str) ; // Construct a date data type, the string is passed
in the above, new date (str ) constructed a date, at least three parts to provide the parameter str date, which is shaped like a "2013/03/08" string can not be "2013/03", otherwise it will get a NaN. At this point of time it is constructed: 2013/03/08 00:00:00. At the same time you can also pass the hours, minutes, and seconds, but can not pass only hours, such as "2013/03/08 17", this parameter will also get a NaN. Parameters can be "2013/03/08 17:20" or "2013/03/08 17:20:05", which can get the correct time, the number of seconds in which if not given, it defaults to 0.
Obtained at this time is the date data type, if a so-called time stamp obtained above, it can be:
var = date.getTime Time ();
thus obtained is a value, expressed from at 0:00 on January 1, 1970 minutes 0 seconds to several milliseconds date moment, if this number is divided by 1000, to obtain the number of seconds is divided by 60 also continues, to give minutes, divided by 60 hours to give the like.
Prompted by the getTime () function, you get two dates milliseconds, and then converted into the number of seconds, minutes, hours or even days, compare the difference between two dates.
How specific timestamp defined I do not know, but Baidu Encyclopedia there are such a sentence: "timestamp is from January 1, 1970 (00:00:00 GMT) time to the current total number of seconds."
According to this definition, the programming language does have a similar function, getTime (), but this function returns January 1 to the current time of the total number of milliseconds since 1970 instead of the total number of seconds.
In the js, converted to a character type is not a difficult Date:
var STR = '2013-08-30'; // date string
str = str.replace (// g, ' /'); // the - replace /, because only supports the following constructors / date string delimited
var date = new date (str) ; // Construct a date data type, the string is passed
in the above, new date (str ) constructed a date, at least three parts to provide the parameter str date, which is shaped like a "2013/03/08" string can not be "2013/03", otherwise it will get a NaN. At this point of time it is constructed: 2013/03/08 00:00:00. At the same time you can also pass the hours, minutes, and seconds, but can not pass only hours, such as "2013/03/08 17", this parameter will also get a NaN. Parameters can be "2013/03/08 17:20" or "2013/03/08 17:20:05", which can get the correct time, the number of seconds in which if not given, it defaults to 0.
Obtained at this time is the date data type, if a so-called time stamp obtained above, it can be:
var = date.getTime Time ();
thus obtained is a value, expressed from at 0:00 on January 1, 1970 minutes 0 seconds to several milliseconds date moment, if this number is divided by 1000, to obtain the number of seconds is divided by 60 also continues, to give minutes, divided by 60 hours to give the like.
Prompted by the getTime () function, you get two dates milliseconds, and then converted into the number of seconds, minutes, hours or even days, compare the difference between two dates.