Javascript - Date valueOf() Method

The valueOf() method returns the primitive value of a Date object.

Description

The valueOf() method returns the primitive value of a Date object.

The primitive value is returned as the number of millisecond since midnight January 1, 1970 UTC.

Syntax

Date.valueOf()

Return

A Number, representing the number of milliseconds between the date object and midnight January 1, 1970 UTC

Example

Return the primitive value of a Date object:

Demo

//display the primitive value of a date object.
var d = new Date();
var n = d.valueOf();
console.log(n);//w  w  w. j a  v  a 2s  . com

Result