Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/444.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Dayjs日历返回错误的格式_Javascript_Calendar_Dayjs - Fatal编程技术网

Javascript Dayjs日历返回错误的格式

Javascript Dayjs日历返回错误的格式,javascript,calendar,dayjs,Javascript,Calendar,Dayjs,我试图在我的工作项目中替换moment.js,最近遇到了一个问题, 下面是返回错误输出的代码 const created_at = '2020-12-23T07:28:19Z'; // today is december 30th const tzIdentifier = 'Asia/Novosibirsk'; const calendar_options = { sameDay: '[Today at] h:mm A', nextDay: '[Tomorrow at] h:mm A',

我试图在我的工作项目中替换moment.js,最近遇到了一个问题, 下面是返回错误输出的代码

const created_at = '2020-12-23T07:28:19Z'; // today is december 30th
const tzIdentifier = 'Asia/Novosibirsk';
const calendar_options = {
  sameDay: '[Today at] h:mm A',
  nextDay: '[Tomorrow at] h:mm A',
  nextWeek: 'dddd [at] h:mm A',
  lastDay: '[Yesterday at] h:mm A',
  lastWeek: '[Last] dddd [at] h:mm A', 
  sameElse: 'DD/MM/YYYY' 
}

day(created_at).tz(tzIdentifier).calendar(null, calendar_options); // always returns sameElse but there should be lastWeek
时区没有什么区别,因为
day(创建于).calendar(null,calendar\u选项)仍然返回相同的EELSE格式

这应该可以:

dayjs.tz(在创建时,tzIdentifier)。calendar(dayjs.tz(tzIdentifier),calendar\u选项)

这应该可以:

dayjs.tz(创建于,tzIdentifier)。日历(dayjs.tz(tzIdentifier),日历选项)