Datepicker displaying wrong day when hosted in Azure

350 views Asked by At

When I debug the website locally it's working fine, however, the website hosted in Azure is displaying yesterday's date. The Azure server is located in my own timezone.

I suspect it's using the UTC time, but shouldn't it just use the local workstation time since it's JavaScript?.

I've configured my JQuery UI datepicker like this:

var today = new Date();
$('.datepick').each(function () {
    $(this).datepicker(
    {
        required: true,
        message: "This is a required field",
        dateFormat: 'dd/mm/yy',
        minDate: today,
        maxDate: addDays(today, 3)
    });
});

My today object is showing the current datetime, as expected.

Debugger

However, the interface is showing yesterday's date:

Datepicker UI

1

There are 1 answers

0
Nic On BEST ANSWER

I'm not sure why this is needed, but I solved it using setDate.

var today = new Date();
$('.datepick').each(function () {
    $(this).datepicker(
    {
        required: true,
        message: "This is a required field",
        dateFormat: 'dd/mm/yy',
        minDate: today,
        maxDate: addDays(today, 3)
    });
    $(this).datepicker("setDate", today);
});