JavaScript getMilliseconds function is one of the Date Function, which returns the number of Milliseconds on a given date.
JavaScript getMilliseconds Function Example
Use the JavaScript get Milliseconds to return the total number of milliseconds in the current date and time.
<!DOCTYPE html> <html> <head> <title> JavaScript Get Milliseconds Function </title> </head> <body> <h1> JavaScript getiMilliseconds Function Example </h1> <script> var dt = Date(); document.write("Date and Time : " + dt); document.write("Milliseconds using getMilliseconds(): " + dt.getMilliseconds()); </script> </body> </html>
JavaScript get Milliseconds Function Example
In this getMilliseconds function example, we are finding the milliseconds from the custom date
<!DOCTYPE html> <html> <head> <title> JavaScript Get Milliseconds Function </title> </head> <body> <h1> JavaScript getMilliseconds Function Example </h1> <script> var dt = Date("December 22, 2016 10:19:45.314"); document.write("Date and Time : " + dt); document.write("Milliseconds using getMilliseconds(): " + dt.getMilliseconds()); </script> </body> </html>
This JavaScript example returns the milliseconds from a custom date without Milliseconds (time). It returns 0 milliseconds.
<!DOCTYPE html> <html> <head> <title> JavaScript Get Milliseconds Function </title> </head> <body> <h1> JavaScript getMilliseconds Function Example </h1> <script> var dt = Date("December 22, 1972"); document.write("Date and Time : " + dt); document.write("Milliseconds using getMilliseconds(): " + dt.getMilliseconds()); </script> </body> </html>