I am extracting the day, month, and year from a date string by calling split
to get each section of the string, and then parsing them individually with parseInt
. This is working in Chrome and Edge, but it is not working correctly in IE11 Enterprise Mode.
This is how the data is populating. But the issue is in 03
. It should return as 3
. If I run the same code in Chrome and Edge, it returns 3
rather than 03
.
Can someone help me resolve this?
var inputDateText = $(this).val(); //30/03/2021
var splitComponents = inputDateText.split('/'); //[30,03,2021]
if (splitComponents.length > 0) {
var day = parseInt(splitComponents[0]); //30
var month = parseInt(splitComponents[1]); //03
var year = parseInt(splitComponents[2]); //2021