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

DateTime time zone America/Mexico_City

I have a grid that display an date, on database and controller, the dates correct, by example: 2017-08-25 21:34:22.000

But, in the Grid display other hour 2017-08-25 16:34:22.000, -5 hours  that are the difference in the time zone America/Mexico_City

The code that use for display the date is:

col.Field("FechaInicial").HeaderText("Fecha Inicial").Format("{0:dd/MM/yyyy hh:mm:ss tt}").TextAlign(TextAlign.Right).Add();

The aplication is hosted in Azure in West of the USA and the users are in Mexico

1 Reply

TS Thavasianand Sankaranarayanan Syncfusion Team August 28, 2017 01:13 PM UTC

Hi Héctor, 

Thanks for contacting Syncfusion support. 

We suspect that you are facing server and client time zone difference issue. DataTime will be parsed in the client-end after retrieved from the server-end. While parsing the DateTime, the conversion will be based on the client time zone. To overcome this problem, you can set the timezone offset from UTC in hours using the ej.serverTimezoneOffset which has been explained in the following Help Document. 


The date-time request on the controller is depend on the server time zone.  

Suppose, application has been hosted in EST time zone and client may be in IST, GMT etc. in that case, date will differ from database. If the client and server has different timezone, storing date-time on server using server timezone which is cause of the issue. 

Refer the below code example to resolve the issue. 


<script type="text/javascript"> 
 
        var serverTimeZoneDiff = -5.0   // if your server is in EST time zone (UTC -5.0) (in hours) 
 
        var clientSideTimeZoneDiff = new Date().getTimezoneOffset() / 60; // get client time zone difference and convert it to hours; 
 
        ej.serverTimezoneOffset = serverTimeZoneDiff + clientSideTimeZoneDiff; 
         
</script> 


If you are still facing any problem, please share the following information to analyze the problem at our end.  

  1. Code example of the Grid
  2. Confirm the version of Essential Studio (14.4.0.15)
  3. If possible, share the hosted sample link.

Regards, 
Thavasianand S. 


Loader.
Up arrow icon