![]() There was a quick popularity contest of some well-liked date-related NPM packages to give you a better idea of what's available. First, you added the days with setDate native function and then used date-fns to do the same things. This quick guide taught you how to add days to a date in JavaScript. Which one to choose is up to you, here is a comparison between the two most popular ones Moment.js and Date-fns. If you have a complex use case then it would be better to pick one of the above libraries to make the more compldex parts easier. Generally, the native JavaScript Date object and its method would suffice your need for date formatting and manipulation. It was created 5 years ago and had 3.8 million downloads for the week ending 1.Īll the above data is taken from NPM Trends and below is a quick snapshot of the popularity of these libraries: Luxon - brands itself as a powerful, modern, and friendly wrapper for JavaScript dates and times.It came into existence 4 years ago and was downloaded 10.2 million times in week 27 of 2022. Day.js - Dubbed the 2Kb fast alternative to Moment.js with the same API.It was created 8 years ago and had 13.6 million downloads for the week ending 1. Date-fns - The package you used in the above example.It was created 11 years ago and had more than 19.5 million downloads in the week ending 1. Probably one of the most feature-rich too. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |