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.
Unfortunately, activation email could not send to your email. Please try again.

Timezone offset

Thread ID:

Created:

Updated:

Platform:

Replies:

127337 Nov 9,2016 05:34 AM Mar 28,2017 11:45 PM ASP.NET MVC 5
loading
Tags: DateTimePicker
Emil Yotov
Asked On November 9, 2016 05:34 AM

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?

Francis Paul Antony Raj [Syncfusion]
Replied On November 10, 2016 01:10 PM

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 


Paul Schaeflein
Replied On March 23, 2017 04:12 PM

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.



Francis Paul Antony Raj [Syncfusion]
Replied On March 27, 2017 01:52 AM

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.  


Paul Schaeflein
Replied On March 27, 2017 09:51 AM

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?

Francis Paul Antony Raj [Syncfusion]
Replied On March 28, 2017 11:45 PM

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.  


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;