Basic Date Formatting Without A Library
JavaScript, on modern browsers, has an Internationalization API that, among other things, provides some date formatting utilities. You can just start using it, no need to import some massive date formatting library.
Here is a Date
object:
The default formatting with this API is a good start:
There are also a number of options for more advanced formatting. Here is the dateStyle
option with the four possible option values:
There is a lot more to this API including localization and custom formatting. Check out the docs for those details.
Last updated