1

I'm using React Rainbow Components date time picker, on the initial Value of date & time, I'm setting it as EST. However, on the trigger of onChange method, the value gets updated based on the browser's local time zone in the state. Ideally, it should update the value in EST only since I'm from India it's updating time in IST format. Passing the locale as "en-US" doesn't work too. Is there any workaround for this, or any idea how to fix this?

import './style.css';

export default function App() {
  const [initialState, updatedState] = useState(new Date());

  const formatedDate = initialState.toLocaleString('en-US', {
    timeZone: 'America/New_York',
  });

  return (
    <div className="App">
      <DateTimePicker
        value={formatedDate}
        minDate={new Date(2022, 0, 4)}
        maxDate={new Date()}
        locale="en-US"
        label="DateTimePicker Label"
        onChange={(value) => updatedState(value)}
      />
    </div>
  );
}

Kaifi Asif
  • 33
  • 4

0 Answers0