JavaScript Date object provides many helpful methods for dealing with date and time. The list is so vast that it is sometimes hard for developers t...
For further actions, you may consider blocking this person and/or reporting abuse
Another approach could be to use Intl.DateTimeFormat.
The toLocaleString() method internally call the Intl’s dateFormat method.
Here is a small read about it from MDN
“ The toLocaleString() method of Date instances returns a string with a language-sensitive representation of this date. In implementations with Intl.DateTimeFormat API support, this method simply calls Intl.DateTimeFormat.”
Hence I guess it already fits the approach you suggested 😀
@atapas Agreed. I was referring to
Intl.DateTimeFormatbecause it may trigger curiosity in the reader. Intl refers to internationalisation, writing for those that don't know what it is.Came for this, specially when the title says "THE BEST" 😅
intlsure is the way to go whenever you want to fully support internationalisation and to cover all edgy cases I can think of.@joelbonetr
Oh, everyone can miss anything. Hence, comments are a great way to contribute to great posts. :-)
Sure! My bad, honestly it's hard to me nowadays to differentiate between click bait and a honest miss 😅
Thanks for the article!
useful
I like the array of months method. A while back I wrote a use case for using dates in Javascript without the Moment library. In this example we populate a stacked bar chart for each month (with plain vanilla js and css)
click here, then get the fully commented source code from my codepen
dev.to/rickdelpo1/how-to-populate-...
Happy coding !!