when i run below code
let m = "5", d = "5", y = "2015"; new Date(`${d}-${m}-${y}`);
firefox developer Edition v 56 return Invalid Date whereas Chrome v 61 return valid and right date.
Tue May 05 2015 00:00:00 GMT+0530 (IST)
Does es6 template literal is not supporting in FF DE 56 browser or there is some definition vary in the browser for Date format?
Kindly suggest any link for help.
This is not caused by template literals, this is caused by non-standard date formatting.
In a Firefox Developer's Edition 56 Scratchpad window:
(new Date(`${d}-${m}-${y}`)).toString()
/*
Invalid Date
*/
(new Date(`${y}-${m}-${d}`)).toString()
/*
Mon May 04 2015 17:00:00 GMT-0700 (Pacific Standard Time)
*/
Here, using the format DD-MM-YYYY is invalid. However, using a standard format of YYYY-MM-DD produces a valid date.
It appears that Chrome may allow additional formats beyond the standard. It is not advised to use non-standard formats since they are not guaranteed to be supported by all major browsers.