Skip to content

Latest commit

 

History

History
69 lines (57 loc) · 1.8 KB

File metadata and controls

69 lines (57 loc) · 1.8 KB
title ms.custom ms.date ms.prod ms.reviewer ms.suite ms.technology ms.tgt_pltfrm ms.topic f1_keywords dev_langs helpviewer_keywords ms.assetid caps.latest.revision author ms.author manager
setTime Method (Date) (JavaScript) | Microsoft Docs
01/18/2017
windows-client-threshold
devlang-javascript
language-reference
setTime
JavaScript
TypeScript
DHTML
SetTime method
time method
86584748-7219-495b-bf56-e27f5782778c
10
mikejo5000
mikejo
ghogen

setTime Method (Date) (JavaScript)

Sets the date and time value in the Date object.

Syntax

  
dateObj.setTime(milliseconds)   

Parameters

dateObj
Required. Any Date object.

milliseconds
Required. A numeric value representing the number of elapsed milliseconds since midnight, January 1, 1970 GMT.

Remarks

If milliseconds is negative, it indicates a date before 1970. The range of available dates is approximately 285,616 years from either side of 1970.

Setting the date and time with the setTime method is independent of the time zone.

Example

The following example illustrates the use of the setTime method.

function SetTimeTest(newtime){  
   var d, s;                  //Declare variables.  
   d = new Date();            //Create Date object.  
   d.setTime(newtime);        //Set time.  
   s = "Current setting is ";  
   s += d.toUTCString();  
   return(s);                 //Return new setting.  
}  

Requirements

[!INCLUDEjsv1]

Applies To: Date Object

See Also

getTime Method (Date)