> 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.settime.md).

# Date.setTime()

Sets a date to a specified number of milliseconds after/before January 1, 1970

The setTime() method sets the Date object to the time represented by a number of milliseconds since January 1, 1970, 00:00:00 UTC.

```javascript
var event1 = new Date('July 1, 1999');
var event2 = new Date();
event2.setTime(event1.getTime());

console.log(event1);
// expected output: Thu Jul 01 1999 00:00:00 GMT+0200 (CEST)

console.log(event2);
// expected output: Thu Jul 01 1999 00:00:00 GMT+0200 (CEST)
// (note: your timezone may vary)

```

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

```javascript
dateObj.setTime(timeValue)
```

#### Parameters <a href="#parameters" id="parameters"></a>

`timeValue`An integer representing the number of milliseconds since 1 January 1970, 00:00:00 UTC.

**Return value**

The number of milliseconds between 1 January 1970 00:00:00 UTC and the updated date (effectively, the value of the argument).

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

Use the `setTime()` method to help assign a date and time to another [`Date`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) object.

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

#### Using `setTime()` <a href="#using_settime" id="using_settime"></a>

```javascript
var theBigDay = new Date('July 1, 1999');
var sameAsBigDay = new Date();
sameAsBigDay.setTime(theBigDay.getTime());
```

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

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

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

Uros Durdevic
