3

I am developing a reactjs application, I want to set timezone to my application.I am using react-datetime package for date and time selection.

My requirement is, My Application need to works with user's selected timezone. For example, In my profile I set America/losangels timezone but I am in India. so the date pickers need to show/give America/losangels date and time but I am getting IST date and time.

Is it possible to change the react-datetime picker timzone?

mx0
  • 6,445
  • 12
  • 49
  • 54
neelima
  • 461
  • 10
  • 25

1 Answers1

8

Use the moment timezone library.

You can then set the default timezone that moment will use (docs:

import moment from 'moment-timezone';
moment.tz.setDefault("America/New_York");

Now, when react-datetime creates/formats new moments, they should be in this timezone.

Brandon
  • 38,310
  • 8
  • 82
  • 87