DEV Community

mhsohag11
mhsohag11

Posted on

Answer: toLocaleDateString() short format

I think the function toLocaleDateString use the default local data on the device.

try this code to check the output:

// America/Los_Angeles for the US
// US English uses month-day-year order
console.log(date.toLocaleDateString('en-US'));
// → "12/19/2012"

// British English uses day-month-year order
console.log(date.toLocaleDateString('en-GB'));
// → "20/12/2012"

// Korean uses year-month-day order

Top comments (0)