Day.js 中文文档

当前版本 v1.11

更多文档

Calendar

Calendar 添加 .calendar API 返回 string 来显示日历时间。

var calendar = require("dayjs/plugin/calendar");
// import calendar from 'dayjs/plugin/calendar' // ES 2015

dayjs.extend(calendar);

dayjs().calendar(dayjs("2008-01-01"));
dayjs().calendar(null, {
  sameDay: "[Today at] h:mm A", // The same day ( Today at 2:30 AM )
  nextDay: "[Tomorrow at] h:mm A", // The next day ( Tomorrow at 2:30 AM )
  nextWeek: "dddd [at] h:mm A", // The next week ( Sunday at 2:30 AM )
  lastDay: "[Yesterday at] h:mm A", // The day before ( Yesterday at 2:30 AM )
  lastWeek: "[Last] dddd [at] h:mm A", // Last week ( Last Monday at 2:30 AM )
  sameElse: "DD/MM/YYYY", // Everything else ( 17/10/2011 )
});

Day.js 中文文档 - 粤ICP备14034220号-1