How can I format dates in Javascript according to the OS date format?

38 Views Asked by At

I'm developing an AngularJS application and we want to display dates in the same format as the user's OS. For example, my OS shows the date as YYYY-MM-DD, so I would like dates to be displayed in the same format.

I tried using toLocalDateString(navigator.language) but this gives me a date format of DD/MM/YYYY, not at all what my OS shows.

Any help is greatly appreciated.

0

There are 0 best solutions below