Home >>JavaScript Date Object Methods >JavaScript Date valueOf() Method
JavaScript Date valueOf() method is an inbuilt function in JavaScript which returns the primitive value of a Date object as a number of milliseconds between 1 January 1970 00:00:00 UTC and the given date.
Syntax:Date.valueOf()
Method | Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
valueOf() | Yes | Yes | Yes | Yes | Yes |
<html> <body> <button onclick="myDvalue()">click me</button> <p id="dateV"></p> <script> function myDvalue() { var d = new Date(); var n = d.valueOf(); document.getElementById("dateV").innerHTML = n; } </script> </body> </html>
<html> <body> <script> var date=new Date("july 27, 1955 22:23:14 GMT+0530 (India Standard Time) "); document.writeln(date.valueOf()); </script> </body> </html>