You can use toLocaleDateString()
method to format a date in JavaScript.
142 chars4 lines
Here, toLocaleDateString()
method takes the locale as the first argument, which specifies the format of the output string. The default locale is the user's locale, which may not be in the desired format. Therefore in this example, the en-US
locale is used to format the date string.
gistlibby LogSnag