The JavaScript date getSeconds() method is used to get the integer value between 0 and 59 that represents the seconds based on the local time.
Syntax:
dateObj.getSeconds()
Return:
An integer value between 0 and 59.
Example:
<!DOCTYPE html> <html> <body> <script> var d = new Date("March 16, 2018 13:34:45:500"); var n = d.getSeconds(); document.writeln(n) </script> </body> </html>