Home  >  Article  >  Web Front-end  >  js Instructions for using = and = date functions (assignment operator)_javascript skills

js Instructions for using = and = date functions (assignment operator)_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:59:191036browse

var s= newDate();
The explanation is as follows: = does not exist;
new Date() is a thing;
is equivalent to .valueOf();
I will add .getTime after seeing the reply. ()This also gets the number of milliseconds

Copy code The code is as follows:

//4 results The same returns the number of milliseconds of the current time
alert( new Date());
alert( new Date);
var s=new Date();
alert(s.valueOf());
alert(s.getTime());

Comes with js for various usages of getting time:
http://www.jb51.net/article/28910. htm

Copy code The code is as follows:

var myDate = new Date ();
var a=myDate.toLocaleString( );
2011-11-07 18:13:56

By the way, another usage of valueOf:

The valueOf() method returns the original value of the Boolean object.

If the object on which this method is called is not a Boolean, a TypeError exception is thrown.
Copy code The 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
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn