How to get Milliseconds on Button Click in JavaScript.
var mydatetime = "31/01/2025 10:10:50.250" var millisecond = ?;
HTML
<input type="button" value="Get Milliseconds" />
Hi makenzi.exc,
Use the getMilliseconds function of Date object to get the Milliseconds.
Refer below example.
<html> <head> <meta charset="utf-8" /> <title></title> <style type="text/css"> body { font-family: Arial; font-size: 10pt; } </style> </head> <body> <input type="button" value="Get Milliseconds" onclick="GetMilliseconds()" /> <script type="text/javascript"> function GetMilliseconds() { var myDate = "2025/01/31 10:12:50.250" //Convert Date string to Date object. var dt = new Date(myDate); // Get Milliseconds. var milliseconds = dt.getMilliseconds(); alert("Milliseconds is: " + milliseconds); } </script> </body> </html>
Demo
Screenshot
Downloads
Download Sample
© COPYRIGHT 2025 ASPSnippets.com ALL RIGHTS RESERVED.