Lightweight Date & Time Nanipulation Library – dayjs

Category: Date & Time , Javascript , Recommended | December 28, 2018
Author: xx45
Views Total: 1,733
Official Page: Go to website
Last Update: December 28, 2018
License: MIT

Preview:

Lightweight Date & Time Nanipulation Library – dayjs

Description:

dayjs is a blazing-fast,  ultra light (2kb) alternative to the moment.js library that helps you parse, validate, manipulate, and display dates and times in pure JavaScript.

Installation:

# NPM
$ npm install dayjs --save

Import the dayjs library into your project.

var dayjs = require('dayjs');
<!-- OR -->
<script src="//unpkg.com/dayjs"></script>

Usage:

All the API are similar to the Moment.js, just replace the ‘moment’ with ‘dayjs’ as follows:

// parse
dayjs('2018-12-21') 

// display
dayjs().format('{YYYY} MM-DDTHH:mm:ss SSS [Z] A')

// get & set
dayjs().set('month', 3).month() 

// manipulate
dayjs().add(1, 'year') 

// query
dayjs().isBefore(dayjs())

Changelog:

12/28/2018

  • Invalid date format return `Invalid date`

12/21/2018

  • v1.7.8: bugfix

06/14/2018

  • v1.6.9: bugfix

06/11/2018

  • v1.6.7: bugfix

You Might Be Interested In:

Leave a Reply