Picks 1 day before
tr2cky opened this issue · 6 comments
From 2016 and backwards when I pick a date, chosen date becomes the day before I picked. For instance when I pick 8/31/2016 from picker, chosen date becomes 8/30/2016. No issues for 2017 and later years.
@tr2cky any update on this yet
<DateTimePicker mode="single" date={dayjs(date).subtract(1, 'day')} onChange={params => { const newdate = ${dayjs(params.date).add(1, 'day')}; setDate(newdate); }} selectedItemColor="red" />
This was how i was able to bypass mine
@farhoudshapouran I could reproduce it here as well.
It happens when your date value also has some time set and when it turns a new day in your current timezone.
I'm not sure on @tr2cky and @Senninseyi cases but, in my one is due to having another input that controls the time part of the value and calendar only controls the date part.
Eg: my current timezone is GMT - 3 and my current date value has a time set too as 8pm. In this case if I open the calendar and start picking dates, that issue won't happen.
But if my time is set to 9pm or later, it then starts to face the issue.
Screen.Recording.2024-07-10.at.12.04.42.PM.mov
@farhoudshapouran我也可以在这里重现它。 当您的日期值也设置了一些时间并且它在您当前的时区中变成了新的一天时,就会发生这种情况。
我不确定@tr2cky和@Senninseyi但在我的例子中,这是因为有另一个输入控制值的时间部分,而日历仅控制日期部分。
例如:我当前的时区是 GMT - 3,并且我当前的日期值也设置了晚上 8 点的时间。在这种情况下,如果我打开日历并开始选择日期,则不会发生该问题。 但如果我的时间设置为晚上 9 点或更晚,就会开始出现问题。
屏幕录制.2024-07-10.at.12.04.42.PM.mov
Have you solved this yet?
When I my app exists in multiple time zones, using this component will select a time that doesn't match the selected time, I think it has something to do with the time zone, but dayjs seems to have problems switching time zones on RN.