Best Options Dates View Dates All Platforms Javascript

Use either simple string manipulation (as suggested by @SKS) or use a library. The latter is more flexible and lets you change the input or output format easily.

For example, using the Globalize.js library, you would write:

Note however that formats such as "dd-mm-yyyy hh:mm" are confusing – it is neither a standard ISO format nor any localized (language-dependent) format. The Globalize.js library lets you use predefined language-dependent formats in addition to explicitly specified formats.

Note that the built-in date and time parsing and formatting routines in JavaScript are implementation-dependent.

Using them means non-portable code. For example, there is no guarantee that will accept the format you have as input, and toLocaleDateString() writes the date in some locale-dependent format, which can be just about anything.

19: Date formats in JavaScript - Learn JavaScript front-end programming