Day.js Extended
Fast 2kB alternative to Moment.js with the same modern API
(This is an extended fork of the original project.)
Day.js is a minimalist JavaScript library that parses, validates, manipulates, and displays dates and times for modern browsers with a largely Moment.js-compatible API. If you use Moment.js, you already know how to use Day.js.
dayjs().startOf('month').add(1, 'day').set('year', 2018).format('YYYY-MM-DD HH:mm:ss');
- 🕒 Familiar Moment.js API & patterns
- 💪 Immutable
- 🔥 Chainable
- 🌐 I18n support
- 📦 2kb mini library
- 👫 All browsers supported
Extensions to the original project
- New plugin "localizableFormat" to format dates according to the chosen locale.
- New plugin "timeZone" to parse from and format to a date string using a time zone specified by its canonical name.
- Corrected plugin "relativeTime" honouring grammar rules of the supported languages.
- "UTC mode" for working in UTC, or for working with date-only values without the time part.
- Additional locales (cs, sk).
- Check for
dayjs
instance by the instanceof
operator.
Getting Started
Installation
npm install dayjs-ext --save
📚Installation Guide
API
It's easy to use Day.js APIs to parse, validate, manipulate, and display dates and times.
dayjs('2018-08-08')
dayjs().format('{YYYY} MM-DDTHH:mm:ss SSS [Z] A')
dayjs().set('month', 3).month()
dayjs().add(1, 'year')
dayjs().isBefore(dayjs())
📚API Reference
I18n
Day.js has great support for internationalization.
But none of them will be included in your build unless you use it.
import 'dayjs-ext/locale/es'
dayjs.locale('es')
dayjs('2018-05-05').locale('zh-cn').format()
📚Internationalization
Plugin
A plugin is an independent module that can be added to Day.js to extend functionality or add new features.
import timeZone from 'dayjs-ext/plugin/timeZone'
dayjs.extend(timeZone)
dayjs().format('D.M.YYYY H:mm',
{ timeZone: 'Europe/Berlin' })
📚Plugin List
See the sponsor list at the original project. Thank you for your support!
Contributors
See the contributor list at the original project. Thank you for your help!
License
Day.js is Extended licensed under a MIT License.