Standard built-ins

Date.prototype.setTime()

Try the free JavaScript compiler

Replace time value with supplied millisecond count after time clipping; returns new timestamp or NaN.

Formal Syntax & Structure

javascript syntaxjavascript
date.setTime(time)

Parameters & Attributes

NameTypeDescription
timeNumberMillisecond timestamp.

Return Value

Number

New timestamp or NaN.

Working Example

Example Snippetjavascript
const d=new Date(0);console.log(d.setTime(5),d.getTime());
JavaScript Reference