Moment.js Date Library
github.com
3
Leaving SiteNav
External Link Disclaimer
You are about to visit github.com. This website is not operated by us. We are not responsible for its content or privacy practices.
About this website
Moment.js is a free and open-source JavaScript date library for parsing, validating, manipulating, and formatting dates. Created by Tim Wood (timrwood) in 2011, Moment.js was the most popular JavaScript date library for nearly a decade, used by millions of projects including Twitter, LinkedIn, and Uber. While now in maintenance mode (the team recommends date-fns, Luxon, or Day.js for new projects), Moment.js remains widely used in legacy codebases. Key features: parsing: parse dates from strings, Unix timestamps, or JavaScript Date objects. moment('2024-01-15') creates a moment object. Supports multiple formats via moment(string, format). Validation: isValid() checks if a parsed date is valid. Formatting: format dates using token strings (format('YYYY-MM-DD HH:mm:ss')). Supports localized formats (format('LL') for long localized date). Arithmetic: add and subtract time units (add(7, 'days'), subtract(2, 'months')). Chaining supported (add(1, 'day').subtract(2, 'hours')). Comparison: isBefore, isAfter, isSame, isBetween, isSameOrBefore, isSameOrAfter for comparing dates. Durals: duration objects for representing lengths of time (moment.duration({ hours: 2, minutes: 30 })). Relative time: fromNow(), toNow(), from(), to() for human-readable relative times ('3 hours ago', 'in 2 days'). Time zones: moment-timezone addon with full IANA timezone database for timezone conversion. Localization: 120+ language locales. Calendar time: calendar() for context-aware date display. UTC: full UTC support with moment.utc(). Plugins: extensive plugin ecosystem. JavaScript. MIT.
Statistics
3
Views
0
Clicks
0
Like
0
Dislike