I am trying to convert string in to date object in but I am getting two different result for two date. Help me to solve this issue and let me know is there any more convenient way to doing this.
<script>
let date1 = '02-11-2022 17:32';
let dateObj1 = new Date(date1);
console.log(dateObj1); // Fri Feb 11 2022 17:32:00 GMT+0530 (India Standard Time)
let date2 = "30-11-2022 17:32";
let dateObj2 = new Date(date2);
console.log(dateObj2); // Invalid Date
</script>