tolocaledatestring format dd-mm-yyyy 1

tolocaledatestring format dd-mm-yyyy

const formatYmd = date => date.toISOString().slice(0, 10);
formatYmd(new Date());  

Here is what the above code is Doing:
1. We create a new Date object with the current date and time.
2. We call the toISOString() method on the Date object.
3. We slice the first 10 characters from the string.
4. We return the result.

Similar Posts