Skip to content

Setting Default Month causes UTC Timezone to not work #2522

Answered by gpbl
romerorisa asked this question in Support
Discussion options

You must be logged in to vote

@romerorisa When working with timezones, you should use TZDate instead of Date:

https://daypicker.dev/docs/time-zone#working-with-time-zoned-dates

- import { DayPicker } from 'react-day-picker';
+ import { DayPicker, TZDate } from 'react-day-picker';

<DayPicker
    mode='single'
    timeZone='UTC'
    captionLayout='dropdown'
-   selected={new Date(Date.parse(selectValue))}
+   selected={new TZDate(year, month, day, timezone)}
/>

Please note that TZDate initializer is different from Date:

https://date-fns.org/v4.1.0/docs/Time-Zones#working-with-time-zones

Replies: 1 comment

Comment options

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