JavaScript & jQuery Tutorials

JS Home Right Arrow JS Reference Right Arrow Date Right Arrow setMilliseconds()

setMilliseconds()  Date  instance method

Description

Sets the locale specific milliseconds (0-999) for the specified date.

Syntax


Signature Description
aDate.setMilliseconds(millisecondsInt)Sets the locale specific milliseconds (0-999) for the specified date.

Parameters


Parameter Description
millisecondsIntAn integer in the range 0-999.
  • For other values the setMilliseconds() method will try and set the date accordingly.

Examples

The code below shows examples of the setMilliseconds() method of Date.




// Create a Date instance for the current date and time.
var todaysDate = new Date();
alert(todaysDate);

// Set and display some dates.
todaysDate.setMilliseconds(100000);
alert(todaysDate + ' - milliseconds set to 100000');

todaysDate.setMilliseconds(10000000000);
alert(todaysDate + ' - milliseconds set to 10000000000');

Press the button below to action the above code:



Related Tutorials

JavaScript Intermediate Tutorials - Lesson 2 - Dates and Times



  

go to home page Homepage go to top of page Top