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.DateTimeFormat because it may trigger curiosity in the reader. Intl refers to internationalisation, writing for those that don't know what it is.
Tech Lead/Team Lead. Senior WebDev.
Intermediate Grade on Computer Systems-
High Grade on Web Application Development-
MBA (+Marketing+HHRR).
Studied a bit of law, economics and design
Location
Spain
Education
Higher Level Education Certificate on Web Application Development
Came for this, specially when the title says "THE BEST" 😅 intl sure is the way to go whenever you want to fully support internationalisation and to cover all edgy cases I can think of.
Tech Lead/Team Lead. Senior WebDev.
Intermediate Grade on Computer Systems-
High Grade on Web Application Development-
MBA (+Marketing+HHRR).
Studied a bit of law, economics and design
Location
Spain
Education
Higher Level Education Certificate on Web Application Development
Rick Delpo - retired Senior Data Engineer from GE now offering a helping hand to Java and SQL beginners. Recently I migrated to AWS Serverless Architecture and moved away from Java to Javascript
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 !!
We're a place where coders share, stay up-to-date and grow their careers.
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 !!