How to convert dd/MM/yyyy string to Date object in JavaScript.
var mydate = "31/01/2025" var dt = ?;
Hi makenzi.exc,
Split the Date string and create instance of new Date object.
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="Submit" onclick="ConvertToDate()" /> <script type="text/javascript"> function ConvertToDate() { var dateString = "26/02/2025".split("/"); //Converting to date object. var dt = new Date(dateString[2], dateString[1] - 1, dateString[0]); alert(dt.toLocaleDateString()); }; </script> </body> </html>
Demo
Screenshot
Downloads
Download Sample
© COPYRIGHT 2025 ASPSnippets.com ALL RIGHTS RESERVED.