Question T11074
Visible to All Users

Datepicker (inputfield, format date) displaying wrong date format in Safari

created 3 years ago

We are using the input field with format date for datepicker.

When the system settings are set to region Sweden, the expected date format on the datepicker UI is yyyy-mm-dd. This works fine in Chrome, but not in Safari.

It seems to be specific to this date format, because when we change the system region to for example UK or US, the date format UI updates to dd/mm/yyyy and mm/dd/yyyy respectively, also in Safari.

Any idea why the Swedish format is not working in Safari?

Show previous comments (1)

    Yes, exactly. We are using the standard datepicker with inputType "date". We would prefer that over the custom widget.

      Got it.
      I guess we need to look at it more closely. I googled this article. We will check the issue and comeback to you.

      Thank you,
      Andrew
      SurveyJS Team

        Hello,

        It looks like YYYY-MM-DD is included in the standard, but for some reason, Safari doesn't support it (https://stackoverflow.com/questions/4310953/invalid-date-in-safari))

        Are you using format property in a survey JSON? Could you share your survey JSON and the steps to reproduce the issue? Is a date entered wrong or it displayed wrong if you set survey.data?

        Thanks, Serge
        SurveyJS Team

        Answers

        created 3 years ago

        We are not using format property. The part of our survey JSON

        {
        "type": "text",
        "name": "counseling_date",
        "title": {
        "sv": "Datum för rådgivningen"
        },
        "hideNumber": true,
        "isRequired": true,
        "inputType": "date"
        },

        Steps to reproduce the issue:

        1. Add an input field to the SurveyJS JSON with inputType: date (see above)
        2. Change your system language/region to Sweden
        3. Enter the Survey UI using Safari - you will see a datepicker. Select any date.
        4. . When date is selected, the date format in the UI will be DD/MM/YYYY instead of the Swedish format YYYY-MM-DD
          Comments (2)

            Hello,

            Thank you for the clarification. It looks like you are using pure HTML/JS INPUT tag with DATE input type. It should use browser settings to format entered date. Unfortunately at this moment I don't see a quick way to fix it in our code.
            In the nearest future - month or two we're planning to implement our own input mask feature for text input tag. Hope we'll address this issue as well.

            Thanks, Serge
            SurveyJS Team

              Ok. Thank you for your answer.