A Lightweight Date & Time Manipulation JavaScript Library | dayjs

dayjs is a blazing-fast,  ultra-light (2kb) various to the second.js library that helps you parse, validate, manipulate, and show dates and instances in pure JavaScript.

date manipulation in javascript, javascript get current date yyyy mm dd, javascript date format, timestamp to date javascript, how to get current time in javascript

Install & Import:

# NPM
$ npm install dayjs --save

Import the day’s library into your challenge.

<!-- Node.js -->
var dayjs = require('dayjs');
<!-- Typescript -->
import * as dayjs from 'dayjs'
<!-- Browser -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dayjs.min.js"></script>

Import locals. You can discover all locals right here.

require('dayjs/locale/de')
<!-- Browser --> 
<script src="https://cdn.jsdelivr.net/npm/[email protected]/locale/de.js"></script>

Import plugins if want. All attainable plugins:

  • SuperiorFormat
  • BuddhistEra
  • Calendar
  • CustomParseFormat
  • DayOfYear
  • Duration
  • IsBetween
  • IsLeapYear
  • IsSameOrAfter
  • IsSameOrBefore
  • IsToday
  • IsTomorrow
  • IsYesterday
  • IsoWeek
  • IsoWeeksInYear
  • LocaleData
  • LocalizedFormat
  • MinMax
  • QuarterOfYear
  • RelativeTime
  • ToArray
  • ToObject
  • UpdateLocale
  • UTC
  • WeekDay
  • weekOfYear
  • WeekYear
var PlugiName = require('dayjs/plugin/pluginname')
<!-- Browser -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/plugin/pluginname.js"></script>

Usage:

All the API are much like the Moment.js, simply change the ‘moment’ with ‘dayjs’ as follows. You can discover the full API right here.

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

// show
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())

// set local
dayjs().locale('de')

Date & Time Manipulation Library, dayjs Github, Day.js Plugin, javascript convert timestamp to date timezone, convert string to date javascript, date in javascript


See Demo And Download

Official Website(iamkun): Click Here

This superior jQuery/javascript plugin is developed by iamkun. For extra Advanced Usages, please go to the official website.

Leave a Comment