Skip to content

Selecting a date in year 0-99AD returns 19XX year. #1108

Answered by KyorCode
ccorcos asked this question in Support
Discussion options

You must be logged in to vote

This is actually due to javascript date behavior. Try it in your console new Date(95, 1, 1) and the year will be 1995, as you stated.

I think the easiest way to overcome is, is to use the parseDate method to correctly parse these dates.
https://react-day-picker.js.org/api/DayPickerInput#parseDate

That in combination for example with date-fns/setYear:

const setYear = require('date-fns/setYear')

const d = setYear(new Date(95,1,1), 95);

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by gpbl
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #983 on February 10, 2021 02:27.