Time zone problem appointments booked outside of allowed range

I have a great system that works for years based on your Scheduler. It makes shop appointments based on workers availability. it was build for CET and works great as long as the client (booker) is in that time zone. If not I sometime see a one hour error (client can book appointment out of worker’s specified working time.) Is there a way to make sure ALL date/time operations are made/shown ALWAYS with local server time? does scheduler.config.server_utc=true may fix it? version is dhtmlxScheduler v.4.4.9 Professional php

Hello @iti,

Yes, the server_utc is designed for the scenario of scheduler usage in different timezones, so it will convert dates to the UTC format and backward(add timezone offset).
In order to avoid some unexpected issues, it’s maybe a good option to create some test environment that is similar to your project config, and test this config in the test environment.

Kind regards,

Hi,
The problem is that the start dates fro working hours are already in DB. So when I change to utc everything shifts and I see completely wrong openning/working hours on scheduler. maybe Best would be to somehow make sure the client sees ALWAYS the local server time, regardless of his own. and when he books his timezone is completely disregarded. Any solution?

Hello @iti,

Unfortunately, there is no built-in option for that as currently scheduler works only with local timezone. The more deep timezone support stays in our future plans, unfortunately there is no ETA(as it requires complicated source changes).

But technically you can implement it through the workaround, by manually adding/decreasing local timeshift before sending events to the backend with the onBeforeDataSending event(in case if you are using dataProcessor, and bring them back while loading events with onEventLoading event, like follows:

scheduler.attachEvent(“onEventLoading”, function(ev){
var start=ev.start_date;
var end=ev.end_date;
var offset=(start.getTimezoneOffset()*-1); //get the shift timezone in minute

//modify the end and start date using scheduler.date.add
ev.start_date=scheduler.date.add(start, offset, ‘minute’);
ev.end_date=scheduler.date.add(end, offset, ‘minute’);
}

	    return true;
	});

So events will be sent to DB with corrected dates, and the corrected dates will be “corrected back” on loading to the client.

Kind regards,

Hi,
will try it. What about summer time correction…?

Hello @iti,

Unfortunately, currently scheduler doesn’t support the DST time changes, as it uses the JS Date object(which doesn’t support DST).

If you are referring to the suggested solution by manual update dates while sending from dataProcessor, you can use some library that supports DST, like moment js, instead of JS Date object.

Kind regards,

Hello,
What is not completely clear to me is why the client time zone is used at all in the agenda. Obviously I save in DB the local times of other appointments, opening times etc. Why and where is the scheduler consider at all the client time zone?. And for what purpose? If the clients choose open slots (generated by back end) Why should their time zones be used at all?. It should not influence any booking at all. If scheduler is using the client time zone, please tell me where it does.