I've found a very interesting issue while working with Date in React.
Here is the function:
const formatDate = (orderDate) => {
const date = new Date(orderDate);
const day = date.getDay();
const month = date.toLocaleString('default', { month: 'long' });
const year = date.getFullYear();
return `${day}-${month.slice(0, 3)}-${year}`;
};
it receives a date as parameter, in my case, orderDate = "05-Feb-2021 06:29:33 PM";
If you run this in Chrome dev tools, it returns the desired result: "5-Feb-2021"
But in Mozilla Firefox, the same operation returns this: "1-Feb--2021"
Why is this happening and how can it be avoided?