Skip to main content
Version: 3.27.2

Date.prototype.valueOf()

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

Syntax

valueOf()

Return value

The number of milliseconds between 1 January 1970 00:00:00 UTC and the given date, or NaN in case of an invalid date.

Description

The valueOf() method returns the primitive value of a Date object as a number data type, the number of milliseconds since midnight 01 January, 1970 UTC.

This method is functionally equivalent to the Date.prototype.getTime() method.

This method is usually called internally by JavaScript and not explicitly in code.