I'm having trouble showing the date in my application. In chrome it works fine, shows the date as expected but in firefox and expolorer it shows NaN-NaN-NaN. I know that if I use a date format with "/" and not "-" than it would work good but I want it to show in a format with "-". Is there a way I can make it work somehow or it only works with "/"?
Here is my code:
formatDate(date) {
let d = new Date(date),
month = '' + (d.getMonth() + 1),
day = '' + d.getDate(),
year = d.getFullYear();
if (month.length < 2)
month = '0' + month;
if (day.length < 2)
day = '0' + day;
return [year, month, day].join('-');
}