DEV Community

Discussion on: Power in tiny libraries

Collapse
 
pretaporter profile image
Maksim • Edited

You can also look to date-fns. It has good tree shaking support.

Collapse
 
nickytonline profile image
Nick Taylor • Edited

+1 for date-fns. As well, the moment folks also create a more lighter weight, tree shakeable version called luxon.

GitHub logo moment / luxon

⏱ A library for working with dates and times in JS

Luxon

MIT License Build Status NPM version Coverage Status Doc coverage PRs welcome

Luxon is a library for working with dates and times in Javascript.

DateTime.local().setZone('America/New_York').minus({ weeks: 1 }).endOf('day').toISO();

Features

  • DateTime, Duration, and Interval types.
  • Immutable, chainable, unambiguous API.
  • Parsing and formatting for common and custom formats.
  • Native time zone and Intl support (no locale or tz files).

Download/install

Download/install instructions

Documentation

Development

See contributing.

Phasers to stun




Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt • Edited

If I am looking for python-dateutil.parser.parse in JavaScript of DateTime string of unknown format; what is the best library, for both Node.js environment and Webpack / Parcel environment?

Also, looking for How to construct a timedelta object from a simple string

Thread Thread
 
tracker1 profile image
Michael J. Ryan

new Date(dateString) does do a pretty good job at parsing on most browsers, but will favor the system locale when MM/dd/yyyy or dd/mm/yyyy is indeterminate.