We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Timezone offset

Hi,
Every control like DateTimePicker, Grid and etc. when application is on cloud server, show time with client timezone offset.

Example:

Data from sql server: 10.11.2016 7:30
Controls show: 10.11.2016 9:30

Server timezone is set to UTC+00:00
Client timezone is: UTC:+02:00

How to remove timezone offset?

5 Replies

FP Francis Paul Antony Raj Syncfusion Team November 10, 2016 06:10 PM UTC

Hi Emil, 
 
Thanks for contacting Syncfusion support. 
 
DateTimePicker changes the time value when the application hosted in different Time zones. As per our source, we have converted the received client time value to UTC (Coordinated Universal Time) before sending it to the server to overcome the time zone discrepancies across the world.  
So, to receive the same date as selected by the user, it requires converting the received time which is in UTC to the local time zone by adjusting the time zone offset. This is depicted in the code provided below.   
 
        // time offset time as TimeSpan object 
        var offsetTime = TimeZoneInfo.Local.GetUtcOffset(DateTime.UtcNow).Ticks; 
 
        // time offset in minutes 
        var localtime_minutes = TimeSpan.FromTicks(offsetTime).TotalMinutes; 
 
        // add the offsetTime to the datetime recieved as UTC 
        ViewData["date"] = data.date.AddMinutes(localtime_minutes); 
 
Please get back to us if you need further assistance. 
 
Regards, 
Francis Paul A 



PS Paul Schaeflein March 23, 2017 08:12 PM UTC

When the DateTime picker initially loads, I am seeing it convert from UTC to local time. However, when posting back to the server, I am not seeing that.

I am UTC -5. I submitted a form with the DTPicker value set to 3:00pm. The form data that is posted is "3/23/2017 3:00 PM". The server, which is set to UTC, interprets the value as 2017-03-23T15:00:00Z 

When the form is re-opened, the server sends the following:
<input id="ScheduleStartDate" name="Schedule.StartDate" type="text" value="3/23/2017 3:00:00 PM" data-ej-value="2017-03-23T15:00:00.000Z" />

When the script runs, it converts the value to UTC-5, which is 10:00am.  

The control is not including the timezone/offset in the form data sent to the server.




FP Francis Paul Antony Raj Syncfusion Team March 27, 2017 05:52 AM UTC

Hi Paul, 
 
Thanks for contacting Syncfusion Support. 
 
We suspect the TimeZone value not updated properly and it causes the DateTimePicker shows wrong value. So, please clear the cache in Visual Studio as mentioned in the below code example to update time zone properly. 
 
[controller.cs]  
  
namespace DatePickerSample.Controllers  
{  
    public partial class DatePickerController : Controller  
    {  
        public ActionResult DatePickerFeatures()  
        {  
              System.Globalization.CultureInfo.CurrentCulture.ClearCachedData(); // clear the cache   
              TimeZone localZone = TimeZone.CurrentTimeZone; // time zone will be updated after clearing the cache   
  
              return View();  
         }   
    }  
}  
 
Please get back to us if you need further assistance on this. 
 
Regards,   
Francis Paul A.  



PS Paul Schaeflein March 27, 2017 01:51 PM UTC

That does not resolve the problem.

If I look at the form data, how is the server supposed to know what timezone the control is using?


FP Francis Paul Antony Raj Syncfusion Team March 29, 2017 03:45 AM UTC

Hi Paul, 
 
We have reproduced the issue (DateTiemPicker value set as wrong Value) when submit the DateTimePicker value after changing the System time zone value in System DateTime settings. To overcome this issue, we suggested the solution provided in the previous update. Please find the sample in the below link: 
 
If we misunderstood your requirement, could you revert the sample with replication procedure to reproduce the issue. Also, please share the EJ version that you have installed in your machine. 
 
Regards, 
Francis Paul A.  


Loader.
Live Chat Icon For mobile
Up arrow icon