Weird problem with date picker field not saving properly dates after or 45 years

Support › MB Frontend Submission › Weird problem with date picker field not saving properly dates after or 45 yearsResolved

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #45244
    AishwaryaAishwarya
    Participant

    Hi,

    I am using the below code
    array(
    'type' => 'date',
    'name' => esc_html__('Test date', 'domain-name'),
    'id' => 'testing_date',
    'js_options' => [
    'dateFormat' => 'dd-mm-yy',
    ],
    'save_format' => 'dd-mm-yy',
    'admin_columns' => true,
    'required' => true,
    ),

    The date picker works fine until I select year 2069. Once I select years above 2069 for example 03-04-2070, it saves the year as 03-04-1970. Vice versa, if I pick 03-04-1970 it saves 2070.

    I tested in multiple fresh installation without any other plugins and no other date picker involved functions except classic editor. It happens on all projects. It accurately records dates within a 45-year range both before and after, but fails to do so for dates beyond that range.

    #45247
    AishwaryaAishwarya
    Participant

    Ok 'save_format' => 'dd-mm-yy', is the problem. 'save_format' => 'd-m-Y', I hope it requires PHP date format. It works fine after changing the save format.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.