Handling timezone in ejSchedule using Drag and Drop

Hi,

I am trying to use the Scheduler drag and drop feature in a timezone environment.

My scenario:
* Server is running in UTC 00:00 (Azure server)
* Clients are in South America and Europe. I am testing it in New Zealand (UTC +13:00) at this moment.
* All date/time values are stored in database without timezone information. I must use this way because this is an old database that can't be changed

The scheduler is working as expected if Drag and Drop is not in use, but if I try to use the drag and drop it is not working.

More details:

Appointment for 2018-03-05 starts 10:01 end 11:01


The time I took the screenshot is: 23:42   (as I said UTC +13:00)

If I drag it to 2018-03-05 16:00 the request is:

You can see that the starttime is 03:00 instead of 16:00. I believe that this is UTC 00:00

So, I am receiving the change as 03:00 (instead of 16:00).

What I already tried:

1. Adding server timeZone to the scheduler - UTC. 
     timeZone: "UTC 00:00",
2.  Adding the browser time zone (UTC +13:00)
     timeZone: "UTC 13:00",
3.  Force a start and end timezone in all records using server timezone UTC 00:00
     startTimeZone: "UTC 00:00",
4.  Force a start and end timezone in all records using server timezone UTC 13:00 (only for testing purposes)
     startTimeZone: "UTC 13:00",
5. I tried the applyTimeOffset: true, but this change all times and it is not correct.

In my development machine (localhost) it work as expected, but my dev machine is in UTC 13:00 server and client.

I am using the control correctly?

My DataManager:
        var dataManager = ej.DataManager({
            url: this.urlAgendaScheduler,
            adaptor: new ej.WebApiAdaptor()
        });

Is there an option to receive the timezone in the request so I can adjust the date/time in the server? i.e. If I receive the ej.Scheduler timeZone in the drag and drop post I can handle it.

Cheers,
Leonardo





3 Replies

KK Karthigeyan Krishnamurthi Syncfusion Team February 15, 2018 06:57 PM UTC

Hi Leonardo, 
 
Thank you for contacting Syncfusion support. 
 
Kindly try the below suggestions. 
 
  1. Maintain same value for TimeZone, StartTimeZone and EndTimeZone fields as shown below.
 
  1. Try ej.serverTimezoneOffset as shown below.
 
<Code> 
           <script type="text/javascript"> 
           var serverTimeZoneDifference = -5.0   // if your server is in EST time zone (UTC -5.0) (in hours) 
           var clientTimeZoneDifference = new Date().getTimezoneOffset() / 60; // get client time zone differences and convert it to hours; 
           ej.serverTimezoneOffset = serverTimeZoneDifference + clientTimeZoneDifference;    
</script> 
</Code> 
 
Regards, 
Karthigeyan 



LJ Leonardo Jose Pires Machado February 16, 2018 01:11 PM UTC

Hi, thanks for your response.

Yeah, you pointed me in the right direction.

I tried the code you sent:
           var serverTimeZoneDifference = -5.0   // if your server is in EST time zone (UTC -5.0) (in hours) 
           var clientTimeZoneDifference = new Date().getTimezoneOffset() / 60; // get client time zone differences and convert it to hours; 
           ej.serverTimezoneOffset = serverTimeZoneDifference + clientTimeZoneDifference;  

But the problem was not solved because:
           var serverTimeZoneDifference = 0.0        // My server is in UTC 0:00
           var clientTimeZoneDifference = new Date().getTimezoneOffset() / 60;   
           // clientTimeZoneDifference = -13         // I am in UTC +13:00
           ej.serverTimezoneOffset = serverTimeZoneDifference + clientTimeZoneDifference;  
           // ej.serverTimezoneOffset = -13          // this is "wrong".

But I found the problem, getTimezoneOffset() method returns the time difference between GMT UTC (00:00) and local time, in minutes. So, in my case, it is returning -780. After dividing by 60 I get -13 UTC. So the real meaning of this offset is that the GMT is 13 hours behind me (-13), this is why the negative result. 

As my servers are configured to be UTC 00:00, I just need to multiply by -1 and everything is correct now. 
When in New Zealand, if the ej.serverTimezoneOffset is equal to 13 then everything works as expected, but -13 would be correct, as the server offset is -13 when compared to my local timezone. 

I tested in other timezones, and for example in Brazil (UTC -3:00) the getTimezoneOffset() returns +3, so GMT is 3 hours ahead of Brazil.

Thank you for your help!

Cheers,
Leonardo



KK Karthigeyan Krishnamurthi Syncfusion Team February 19, 2018 08:28 AM UTC

 
Thanks for your update. 
 
We are happy that your issue has been resolved. 
 
Regards, 
Karthigeyan 



Loader.
Up arrow icon