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.
I cannot set the timezone for the display so this is always displaying the times in the timezone of the browser.
Create a datetime picker in a different timezone than your browser.
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.
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
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 .