Home Javascript JavaScript getMilliseconds method



JavaScript getMilliseconds method
Posted on: February 7, 2009 at 12:00 AM
JavaScript method getMilliseconds() returns the milliseconds value in the Date object using the local time.

JavaScript getMilliseconds method

     

JavaScript method getMilliseconds() returns the milliseconds value in the Date object using the local time. 

 

 

 

 

 

 

 function getTimeInMilliFunc(){
		var myDate = new Date(); 
	    	alert(myDate.getMilliseconds());
	    }

To illustrate getMilliseconds() method here we have created a button in the HTML page when you click on this button it calls the function getTimeInMilliFunc() as defined in the script tag. In the above code getMilliseconds() returns a three digit number that represents time in milliseconds from the local time.

Here is the full JavaScript code with HTML code as follows:

<html>
<head>
	<title>Get time in milliseconds</title>
	<script>
	function getTimeInMilliFunc(){
			var myDate = new Date(); 
	    	alert(myDate.getMilliseconds());
	    	}
	</script>	
</head>
<body>
<div style="background: #f3449c; width:'100%';"
 align="center">
  <font color="#0000ff" size="12pt">
	<b>Get time in milliseconds</b>
  </font>
 </div>
  <center>
  <p>&nbsp;</p>
  <input type="button" onclick="getTimeInMilliFunc();"
     value="Time in milliseconds">
</center>
</body>
</html>

Output :

When you will click on the button "Time in milliseconds" it will show the time in milliseconds from the date object into local time.

You can also download full HTML code from the following link.

Download Source Code

     

Related Tags for JavaScript getMilliseconds method:
javajavascriptcdatetimescriptobjectmethodgetipvaluereturnusinglocaleilliimincalasmmillisecondscajmillisecondlocmeobjsurnatisimellsecondsvascrssriripthcondavalujemindono


More Tutorials from this section

Ask Questions?    Discuss: JavaScript getMilliseconds method  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.