Dates
Date() // => "Tue Jan 21 2020 23:50:09 GMT-0800 (Pacific Standard Time)"
let x = new Date() //create Date object
x.toDateString(); //=> "Tue Jan 21 2020"
x.toISOString(); //=> "2018-12-31T03:21:15.934Z"
x.toGMTString(); //=> "Wed, 22 Jan 2020 07:48:33 GMT"
x.toLocaleDateString(); //=> "1/21/2020"npm install date-fnsimport { format, compareAsc } from 'date-fns'
// Add any duration to 1 September 2014, 10:19:50
const result = add(new Date(2014, 8, 1, 10, 19, 50), {
years: 2,
months: 24,
days: 7,
hours: 5,
minutes: 9,
seconds: 30,
})Formatting
Formatting Strings
Unit
Pattern
Result examples
Notes
Moment.js (Similar to Dayjs)
Creation
Formatting
Operations
Operations
Plugins
Last updated