[英]dayjs returns wrong date with format
I'm trying to convert a date to a readable format.我正在尝试将日期转换为可读格式。
For example:例如:
var dayjs = require('dayjs')
const date = '1989-08-12T01:00:00.000Z'
console.log(dayjs(date).format('DD/MM/YYYY'))
The result shows: 11/08/1989结果显示: 11/08/1989
Expected behavior A clear and concise description of what you expected to happen.预期行为 对您预期会发生的事情的清晰简明描述。
I expect that the log should return 12 /08/1989 instead of 11 /08/1989我希望日志应该返回12 /08/1989 而不是11 /08/1989
Day.js Version: v1.8.16 Day.js版本:v1.8.16
Not sure if I miss any parameters or not.不知道我是否错过了任何参数。 Thanks,
谢谢,
Your input is timezone 0, but the output is your timezone.您的输入是时区 0,但 output 是您的时区。 You can change your code to
您可以将代码更改为
var dayjs = require('dayjs')
const date = '1989-08-12T01:00:00.00' // remove 0Z
console.log(dayjs(date).format('DD/MM/YYYY'))
Your problem is the same with https://github.com/iamkun/dayjs/issues/323您的问题与https 相同://github.com/iamkun/dayjs/issues/323
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.