I got a snippet of code that gets the date out of a xml file. And i found a snippet that converts the date dd/mm/yyyy. This code works fine in Google Chrome but it does not work fine in Firefox, IE or Edge... In the browsers were the code does not work, the function returns NaN/NaN/NaN. But for example: in Google Chrome there is 12/2/2016 retruned. the format of dateFormXml is yyyy/mm/dd and the output format is dd/mm/yyyy Here is my code:
function dateConverter(dateFromXml){
function format(x){
//if the day/month is smaller then 10 add a 0 in front of it (9->09)
return (s < 10) ? '0' + x : x;
}
var d = new Date(dateFormXml),
convertedDate = [format(d.getDate()), format(d.getMonth() + 1), d.getFullYear()].join('/');
return convertedDate;
}
Can anyone help me to make this cross browser please? :)