Home >>JavaScript Date Object Methods >JavaScript Date valueOf() Method

JavaScript Date valueOf() Method

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()

Browser Support

Method Chrome Edge Firefox Safari Opera
valueOf() Yes Yes Yes Yes Yes
Here is an example of JavaScript Date valueOf() Method:
<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>
Output:

Example 2:
<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>
Output:

No Sidebar ads