How to get seconds from Date Time in JavaScript.
Example: here the second value is 50.
var mydatetime = "31/01/2025 10:10:50" var second = 50;
Please asist.
Hi makenzi.exc,
Use the getSeconds function of Date object to get the Seconds.
Refer below example.
HTML
<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 Seconds" onclick="GetSeconds()" /> <script type="text/javascript"> function GetSeconds() { var myDate = "2025/01/31 10:12:50" //Convert Date string to Date object. var dt = new Date(myDate); // Get Seconds. var seconds = dt.getSeconds(); alert("Second is: " + seconds); } </script> </body> </html>
Demo
Screenshot
Downloads
Download Sample
© COPYRIGHT 2025 ASPSnippets.com ALL RIGHTS RESERVED.