Home > database >  DayJS historical date format issue
DayJS historical date format issue

Time:04-21

DayJS format() incorrectly converts almost any historical date. In this example I try to format the year 2 AD (from user input). The output is the year 1902 AD, which is absolutely wrong. Now I am wondering if I got this method wrong or it is actually a bug and of course how to solve this anyway.

Have created a Codepen for this

const formatedDate = dayjs('0002-05-01', 'YYYY-MM-DD').format('YYYY-MM-DD')
console.log(formatedDate)
//Output: "1902-05-01"

CodePudding user response:

There is an open issue somebody solved this with setting new Date().setFullYear(2). I hope it helps

  • Related