A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/javascript-date-settime-function/ below:

JavaScript Date setTime() Function - GeeksforGeeks

JavaScript Date setTime() Function

Last Updated : 23 Jul, 2025

The JavaScript Date setTime() Function is a built-in Function in Javascript that is used to get a date object by adding given milliseconds to the date 01/01/1970

Syntax:

date.setTime(milliseconds)

Parameters: setTime() Function takes parameters as follows.

Return Value: The setTime() Function returns milliseconds between January 1 1970 and the time you passed in the parameter.

Example 1: Adding 300000000000 milliseconds to 01/01/1970

JavaScript
<script>
    // Initialization
    let date = new Date();
    
    // Execution
    let output = date.setTime(300000000000);
    
    // Display Output
    console.log(`setTime() Output:`, output, date);
</script>

Output:

setTime() Output: 300000000000 Thu Jul 05 1979 10:50:00 GMT+0530 (India Standard Time)

Example 2: Subtracting 300000000000 milliseconds to 01/01/1970.

JavaScript
<script>
    // Initialization
    let date = new Date();
    
    // Execution
    let output = date.setTime(-300000000000);
    
    // Display Output
    console.log(`setTime() Output:`, output, date);
</script>

Output:

setTime() Output: -300000000000 Thu Jun 30 1960 00:10:00 GMT+0530 (India Standard Time)

We have a complete list of Javascript Date Objects, to check those please go through this Javascript Date Object Complete reference article.

Supported Browsers: The browsers supported by the JavaScript Date setTime() Function are listed below: 

We have a Cheat Sheet on Javascript where we covered all the important topics of Javascript to check those please go through Javascript Cheat Sheet-A Basic guide to JavaScript.



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4