THE WORLD'S LARGEST WEB DEVELOPER SITE

JS Reference

Overview

JavaScript

JS Array JS Boolean JS Date JS Error JS Global JS JSON JS Math JS Number JS Operators JS RegExp JS Statements JS String

HTML DOM

DOM Attribute DOM Console DOM Document DOM Element DOM Events DOM Event Objects DOM Geolocation DOM History DOM HTMLCollection DOM Location DOM Navigator DOM Screen DOM Style DOM Window WEB Storage

HTML Objects

<a> <abbr> <address> <area> <article> <aside> <audio> <b> <base> <bdo> <blockquote> <body> <br> <button> <canvas> <caption> <cite> <code> <col> <colgroup> <datalist> <dd> <del> <details> <dfn> <dialog> <div> <dl> <dt> <em> <embed> <fieldset> <figcaption> <figure> <footer> <form> <head> <header> <h1> - <h6> <hr> <html> <i> <iframe> <img> <ins> <input> button <input> checkbox <input> color <input> date <input> datetime <input> datetime-local <input> email <input> file <input> hidden <input> image <input> month <input> number <input> password <input> radio <input> range <input> reset <input> search <input> submit <input> text <input> time <input> url <input> week <kbd> <label> <legend> <li> <link> <map> <mark> <menu> <menuitem> <meta> <meter> <nav> <object> <ol> <optgroup> <option> <output> <p> <param> <pre> <progress> <q> <s> <samp> <script> <section> <select> <small> <source> <span> <strong> <style> <sub> <summary> <sup> <table> <td> <th> <tr> <textarea> <time> <title> <track> <u> <ul> <var> <video>

Other References

CSSStyleDeclaration JS Conversion


JavaScript setTime() Method

❮ JavaScript Date Object

Example

Add 1332403882588 milliseconds to January 1, 1970, and display the new date and time:

var d = new Date();
d.setTime(1332403882588);
Try it Yourself »

More "Try it Yourself" examples below.


Definition and Usage

The setTime() method sets a date and time by adding or subtracting a specified number of milliseconds to/from midnight January 1, 1970.


Browser Support

Method
setTime() Yes Yes Yes Yes Yes

Syntax

Date.setTime(millisec)

Parameter Values

Parameter Description
millisec Required. The number of milliseconds to be added to, or subtracted from, midnight January 1, 1970


Technical Details

Return Value: A Number, representing the number of milliseconds between the date object and midnight January 1 1970
JavaScript Version: ECMAScript 1

More Examples

Example

Subtract 1332403882588 milliseconds from January 1, 1970, and display the new date and time:

var d = new Date();
d.setTime(-1332403882588);
Try it Yourself »

❮ JavaScript Date Object