Var s = + newDate ();
The explanation is as follows: = + does not exist;
+ New Date () is a thing;
+ Equivalent to. valueOf ();
See the reply to add. getTime (), which also gets the number of milliseconds.
Copy codeThe Code is as follows:
// Returns the same number of milliseconds as the four results.
Alert (+ new Date ());
Alert (+ new Date );
Var s = new Date ();
Alert (s. valueOf ());
Alert (s. getTime ());
The following describes how to use js to obtain the time:
Http://www.jb51.net/article/28910.htm
Copy codeThe Code is as follows:
Var myDate = new Date ();
Var a = myDate. toLocaleString ();
2011-11-07 18:13:56
By the way, valueOf has another usage:
The valueOf () method returns the original value of a Boolean object.
If the object that calls this method is not Boolean, an exception TypeError is thrown.
Copy codeThe Code is as follows:
Var boo = new Boolean (false );
Document. write (boo. valueOf ());
Other usage: http://www.jb51.net/w3school/js/jsref_valueof_math.htm