Question T8406
Visible to All Users

Is it possible to set date in datepicker based on UTC timezone?

created 3 years ago (modified 3 years ago)

[Ticket cloned from T6378: Set minValue for datepicker based on input from another datepicker]

Is it possible to set date in datepicker based on UTC timezone?
Currently, today() works differently for both IST and PST, so is it possible to pick a timezone to set today() in date picker?

Answers approved by surveyjs Support

created 3 years ago

Hello,

You can declare your own function instead of today and support UTC in it:

JavaScript
function utcToday(params: any[]) { var res = new Date(); res.setUTCHours(0, 0, 0, 0); if (Array.isArray(params) && params.length == 1) { res.setDate(res.getDate() + params[0]); } return res; } Survey.FunctionFactory.Instance.register("utcToday", utcToday);

Thanks, Serge
SurveyJS Team

    Show previous comments (7)

      How can I reset the date programmatically ?
      I want to access the DOM element and reset the value via some javascript function.

        Hello Komal,
        Here is the correct way to do it.
        survey.getQuestionByName("yourQuestionName").clearValue();

        Thank you,
        Andrew
        SurveyJS Team

          Perfect, thanks :)