Subscribe to my email list now at http://jauyeung.net/subscribe/
Follow me on Twitter at https://twitter.com/AuMayeung
Many more articles at http...
For further actions, you may consider blocking this person and/or reporting abuse
2020-01-01 1:00
, so that Date constructor / moment doesn't complain (without directly specifying Date format)?This is the closest thing I can find to format dates in the format you ask for gist.github.com/noromanba/6737784
I think date-fns is also good.
Open your console and type
Intl
you might find some very useful date formatting power in this API as well as a bunch of other good stuff.There's actually a lot of features for internationalization un JavaScript, like sorting strings in a locale-sensitive manner, formatting numbers, plurals, lists, and showing relative time.
Dates are just the beginning.
I like the currency section of this API, fantasticly under utilized though 😅
Yea. I only discovered it on MDN when I'm writing about it.
you might also like to have a look at the JS date and time formatting functions
new Date().toLocaleDateString("en-GB", options);
new Date().toLocaleTimeString("en-GB")
toLocaleDateString
actually has lots of options to format dates.It's also sensitive to locale, which is handy for formatting dates in any format in the world almost.