react-datepicker icon indicating copy to clipboard operation
react-datepicker copied to clipboard

Selects wrong date when typing date with leading 0 on month in timezones that are behind UTC

Open scott-moxham opened this issue 2 years ago • 2 comments

Describe the bug When the computer has a timezone selected that is behind UTC, e.g. Hawaii, typing the date "2023-02-07" will select the date 6th of February 2023.

If you type "2023-2-07" it will correctly select the 7th of February 2023.

If your computer is set to use UTC or a timezone ahead of UTC, e.g. Australia, then both strings will select the correct date.

To Reproduce Steps to reproduce the behavior: My react code

<DatePicker
    className={styles['date-range-custom-dates-start']}
    onChange={(val: Date) => { store.setPopupStart(val); }}
    selected={store.popupStartDate}
    name="customDateStart"
    autoComplete="off"
    dateFormat="P"
    locale="currentLocale"
    isClearable
/>
  1. Set timezone to be Hawaii
  2. Click on the datepicker field
  3. Type "2023-02-07"

The 6th of February is incorrectly selected

Expected behavior The 7th of February 2023 should be selected

Screenshots image

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser Microsoft Edge
  • Version 115.0.1901.203 (Official build) (64-bit)

Additional context Add any other context about the problem here.

scott-moxham avatar Aug 24 '23 17:08 scott-moxham

Any updates? I have same error

nikitadubyk avatar Nov 23 '23 08:11 nikitadubyk

This solution might work for you: https://stackoverflow.com/a/67599505/5071753

marcelkooi avatar Nov 23 '23 16:11 marcelkooi

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 10 days.

github-actions[bot] avatar May 29 '24 01:05 github-actions[bot]