JavaScript getMinutes function is one of the Date Functions, which returns the number of minutes on a given date.
JavaScript getMinutes Example
The following getMinutes function returns the total minutes in the current date and time.
<!DOCTYPE html> <html> <head> <title> JavaScriptGetMinutesFunction </title> </head> <body> <h1> JavaScriptgetMnutesFunctionExample </h1> <script> var dt = Date(); document.write("Date and Time : " + dt); document.write("Minutes from getMinutes(): " + dt.getMinutes()); </script> </body> </html>
In this get example, we extract the minutes from the custom date.
<!DOCTYPE html> <html> <head> <title> JS </title> </head> <body> <h1> Example </h1> <script> var dt = Date("April 31, 2012 12:09:07"); document.write("Date and Time : " + dt); document.write("Minutes : " + dt.getMinutes()); </script> </body> </html>
Example
Date and Time: Tue May 01 2012 12:09:07 GMT+0530 (Indian Standard Time)
Minutes : 9
In this JavaScript example, we extract the minutes from the custom date without time (minutes). This will return 0 minutes.
<!DOCTYPE html> <html> <head> <title> JS </title> </head> <body> <h1> Example </h1> <script> var dt = Date("April 31, 2012"); document.write("DateTime : " + dt); document.write("Minutes : " + dt.getMinutes()); </script> </body> </html>
Example
DateTime: Tue May 01 2012 00:00:00 GMT+0530 (Indian Standard Time)
Minutes : 0