moment('2019-03-31 09:00:00').get('hour') // moment('2019-03-31 09:00:00').get('H')
dayjs('2019-03-31 09:00:00').get('hour') // dayjs('2019-03-31 09:00:00').hour()
moment.isDate(new Date());
dayjs.isDate(new Date()); // dayjs(new Date()).isValid();
moment().isoWeeksInYear();
import isoWeeksInYear from 'dayjs/plugin/isoWeeksInYear';dayjs.extend(isoWeeksInYear);
dayjs().isoWeeksInYear();
Maximum/Minimum of the given dates
moment.max(array.map(a => moment(a)));
moment.min(array.map(a => moment(a)));
import minMax from 'dayjs/plugin/minMax';dayjs.extend(minMax);
dayjs.max(array.map(a => dayjs(a)));
dayjs.min(array.map(a => dayjs(a)));
moment().week(24);
import weekOfYear from 'dayjs/plugin/weekOfYear';dayjs.extend(weekOfYear);
dayjs().week(24);
moment().dayOfYear();
moment().dayOfYear(256);
import dayOfYear from 'dayjs/plugin/dayOfYear';dayjs.extend(dayOfYear); dayjs().dayOfYear();
dayjs().dayOfYear(256);
moment('2012 mars', 'YYYY MMM', 'fr');
import customParseFormat from 'dayjs/plugin/customParseFormat'; import 'dayjs/locale/fr'; dayjs.extend(customParseFormat);
dayjs('2012 mars', 'YYYY MMM', 'fr');
moment('2010-10-20 4:30', 'YYYY-MM-DD HH:mm');
import customParseFormat from 'dayjs/plugin/customParseFormat'; dayjs.extend(customParseFormat);
dayjs('2010-10-20 4:30', 'YYYY-MM-DD HH:mm');
moment.duration(100)
import duration from 'dayjs/plugin/duration'; dayjs.extend(duration)
dayjs.duration(100)
moment('2010-10-20').isBetween('2010-10-19', '2010-10-25')
import isBetween from 'dayjs/plugin/isBetween'; dayjs.extend(isBetween);
dayjs('2010-10-20').isBetween('2010-10-19', '2010-10-25');
moment(1536484369695).fromNow();
import relativeTime from ; dayjs.extend(relativeTime);
dayjs(1536484369695).fromNow();
moment([2007, 0, 27]).to(moment([2007, 0, 29]));
import relativeTime from 'dayjs/plugin/relativeTime';dayjs.extend(relativeTime);
dayjs('2007-01-27').to(dayjs('2007-01-29'));
moment([2000]).isLeapYear();
import isLeapYear from 'dayjs/plugin/isLeapYear';dayjs.extend(isLeapYear);
dayjs('2000-01-01').isLeapYear();
moment('2019-03-31 09:00:00').calendar(moment().add(1, 'd'))
import calendar from 'dayjs/plugin/calendar'; dayjs.extend(calendar)
dayjs('2019-03-31 09:00:00').calendar(dayjs().add(1, 'd'))
moment('2010-10-20').isAfter('2010-10-19');
dayjs('2010-10-20').isAfter('2010-10-19');
moment().format('dddd, MMMM Do YYYY, h:mm:ss A');
moment().format('ddd, hA');
dayjs().format('dddd, MMMM D YYYY, h:mm:ss A');
dayjs().format('ddd, hA');
moment().startOf('month');
moment().endOf('day');
dayjs().startOf('month');
dayjs().endOf('day');
moment('2010-10-20').isSame('2010-10-21');
moment('2010-10-20').isSame('2010-10-21', 'month');
dayjs('2010-10-20').isSame('2010-10-21');
dayjs('2010-10-20').isSame('2010-10-21', 'month');
moment('2012-02', 'YYYY-MM').daysInMonth();
dayjs('2012-02').daysInMonth();
moment().date();
moment().date(4);
dayjs().date();
dayjs().set('date', 4);
moment().day();
moment().day(-14);
dayjs().day();
dayjs().set('day', -14);
moment('2010-10-20').isBefore('2010-10-21');
dayjs('2010-10-20').isBefore('2010-10-21');
moment().seconds(); / moment().second()
moment().hours(); / moment().hour();
dayjs().second(); / dayjs().seconds();
dayjs().hour(); / dayjs().hours();
moment().seconds(30);
moment().hours(13);
dayjs().set('second', 30);
dayjs().set('hour', 13);
moment().add(7, 'days'); / moment().add(7, 'day');
dayjs().add(7, 'days'); / dayjs().add(7, 'day');
moment().subtract(7, 'days');
dayjs().subtract(7, 'day');
moment([2007, 0, 27]).diff(moment([2007, 0, 29]));
moment([2007, 0, 27]).diff(moment([2007, 0, 29]), 'days');
dayjs('2007-01-27').diff(dayjs('2007-01-29'), 'milliseconds');
dayjs('2007-01-27').diff(dayjs('2007-01-29'), 'days');
{
"resolve": {
"alias": {
"moment": "dayjs"
} }}
dayjs__WEBPACK_IMPORTED_MODULE_13___default.a.max is not a function
通过 引入对应的插件可以实现
import minMax from 'dayjs/plugin/minMax';dayjs.extend(minMax);