React-datepicker: Timezone are not working properly

Created on 19 Mar 2019  路  3Comments  路  Source: Hacker0x01/react-datepicker

Expected behavior

I need to set the timezone so that I see the dates in the timezone I want even if it is not the timezone of my browser. Example: I am in America/Montreal, I want to see and select times in Europe/Paris timezone, as I need to rent a car over there. So when I set a date I should be able to set it in utc or whatever timezone and precise the timezone of the display.

Actual behavior

I cannot set the timezone for the display so this is always displaying the times in the timezone of the browser.

Steps to reproduce

Create a datetime picker in a different timezone than your browser.

Workaround

I defined the timezone I want with moment-timezone. Example:

moment.tz.setDefault(timezone_i_want);

I set the datetimes in state as string with moment().format() so that I get something like "2019-03-19T17:32:24+01:00" and then to display it with the date picker I use new Date(moment(""2019-03-19T17:32:24+01:00").format('lll')). Then in the change methods I set only the hours and minutes of the original date.

I was expecting to use utcoffset but it doesnt work, + I dont see the use of utcoffset in your code.

wontfix

Most helpful comment

Yep, it's sad but this repo is not actively maintained, so I think in the future it will degrade a lot more.

In the meantime we can use https://github.com/airbnb/react-dates .

All 3 comments

Yep, it's sad but this repo is not actively maintained, so I think in the future it will degrade a lot more.

In the meantime we can use https://github.com/airbnb/react-dates .

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

it not working for me . please recheck . am assign the time zone before rendering my component . but it's taking my browser ,timing . am in India . but i want to display the africa/lagos time

Was this page helpful?
0 / 5 - 0 ratings

Related issues

goxr3plus picture goxr3plus  路  3Comments

ro-savage picture ro-savage  路  3Comments

arturictus picture arturictus  路  3Comments

kkras3 picture kkras3  路  3Comments

sarav1234 picture sarav1234  路  3Comments