> For the complete documentation index, see [llms.txt](https://date.gitbook.io/dateall/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://date.gitbook.io/dateall/javascript/methods/date.valueof.md).

# Date.valueOf()

Returns the primitive value of a Date object

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

```javascript
var date1 = new Date(Date.UTC(96, 1, 2, 3, 4, 5));

console.log(date1.valueOf());
// expected output: 823230245000

var date2 = new Date('02 Feb 1996 03:04:05 GMT');

console.log(date2.valueOf());
// expected output: 823230245000

```

## Syntax <a href="#syntax" id="syntax"></a>

```javascript
dateObj.valueOf()
```

**Return value**

The number of milliseconds between 1 January 1970 00:00:00 UTC and the given date.

## Description <a href="#description" id="description"></a>

The `valueOf()` method returns the primitive value of a [`Date`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/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()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTime) method.

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

## Examples <a href="#examples" id="examples"></a>

#### Using `valueOf()` <a href="#using_valueof" id="using_valueof"></a>

```javascript
var x = new Date(56, 6, 17);
var myVar = x.valueOf();      // assigns -424713600000 to myVar
```

## References <a href="#references" id="references"></a>

{% embed url="<https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/valueOf>" %}

## Contributors to this page <a href="#contributors-to-this-page" id="contributors-to-this-page"></a>

Uros Durdevic
