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

How to completely disable datetime timezone correction in Grid?

I am using UrlAdaptor, so all data transferred in JSON, so I can control how the JSON datetime serialized handle datetime

The server send the dates in UTC for example: DateTimeData=2020-06-01T04:00:00Z, 
The ej.data.DataUtil.serverTimezoneOffset is not touched (it is null). 

The grid renders datetime according to the browser's timezone setting.
I would like the grid do not touch the datetimes at all, I would like to display them in UTC (or untouched) regardless of any browser timezone





1 Reply

FS Farveen Sulthana Thameeztheen Basha Syncfusion Team June 4, 2019 10:53 AM UTC

Hi Gabor, 

Thanks for contacting Syncfusion Support. 

Query#:- I would like the grid do not touch the datetimes at all, I would like to display them in UTC (or untouched) regardless of any browser timezone 
 
We have achieved your requirement “display date in UTC format without any browser timeZone” using CustomAdaptor by extending the UrlAdaptor on load event  and convert the date value to UTC before binding value into the Grid in the processResponse method. 
 
Please refer to the code example:- 
 
<ej-grid id="FlatGrid" allow-paging="true" load="load"> 
       <e-datamanager url="/Home/DataSource" adaptor="UrlAdaptor"></e-datamanager> 
     <e-columns> 
        <e-column field="OrderID" header-text="Order ID" text-align="Right" is-primary-key="true"></e-column> 
               .   .    . 
    </e-columns> 
</ej-grid> 
<script> 
    function load(args) { 
              this.model.dataSource.adaptor = new customadaptor(); 
      } 
 
    var customadaptor = new ej.UrlAdaptor().extend({ 
        processResponse: function (data, ds, query, xhr, request, changes) { 
 
             var res = JSON.parse(xhr.responseText); 
             for (var i = 0; i < res.result.length; i++) { 
                var date = res.result[i].Date.split("(")[1].split(")")[0];  // use your date column field name 
                value = new Date(parseInt(date)).toUTCString() 
                data.result[i].Date = value; 
                
            } 
            return this.base.processResponse.apply(this, [data, ds, query, xhr, request, changes]); 
        } 
    }); 
 
</script> 
 
Please get back to us if you need any further assistance. 

Regards, 
Farveen sulthana T 


Loader.
Live Chat Icon For mobile
Up arrow icon