In modern browsers, [Date.prototype.toLocaleDateString()](<https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString>)
allows you to define the formatting of a Date
in a convenient manner.
It requires the following format :
dateObj.toLocaleDateString([locales [, options]])
The locales
parameter should be a string with a BCP 47 language tag, or an array of such strings.
The options
parameter should be an object with some or all of the following properties:
"lookup"
and "best fit"
; the default is "best fit"
"UTC"
; the default is the runtime’s default time zonetrue
and false
; the default is locale dependent"basic"
and "best fit"
; the default is "best fit"
"narrow"
, "short"
& "long"
"narrow"
, "short"
& "long"
"numeric"
& "2-digit"
"numeric"
, "2-digit"
, "narrow"
, "short"
& "long"
"numeric"
& "2-digit"
"numeric"
& "2-digit"
"numeric"
& "2-digit"
"numeric"
& "2-digit"
"short"
& "long"