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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

show timestamp in column as datetime

Thread ID:





128672 Feb 4,2017 12:00 PM UTC Mar 9,2017 06:43 AM UTC JavaScript 7
Tags: ejGrid
Razgovorov Mikhail
Asked On February 4, 2017 12:00 PM UTC

the data source for the grid I have one of the fields contains a Unix timestamp. whether there is an opportunity to show it as a date time?

Ragavee U S [Syncfusion]
Replied On February 6, 2017 11:42 AM UTC

Hi Razgovorov, 

Thanks for your interest in Syncfusion products. 

You can parse the timestamp using ej.parseJSON method before assigning dataSource to Grid and using the format property of the grid columns, you can assign required format in which the date to be displayed. Please refer to the below demo sample. 

Ragavee U S. 

Razgovorov Mikhail
Replied On February 8, 2017 08:37 PM UTC

Thanks for the answer, but I need more.
is it possible to display the timestamp as a date, for example, for such data
       var data1 = [
                    { "OrderID": 10253, "OrderDate": 1454756603000},
                    { "OrderID": 10253, "OrderDate": 1486379003000}

Ragavee U S [Syncfusion]
Replied On February 9, 2017 08:56 AM UTC

Hi Razgovorov, 

Yes. We can achieve your requirement by extending the adaptor and parsing the value as Date using JavaScript new Date method and then assigning it as dataSource to Grid. 

In the above sample, we have extended the processResponse function of the JsonAdaptor and thus have parsed the value of “OrderDate” field as Date Object. 

Ragavee U S. 

Razgovorov Mikhail
Replied On February 19, 2017 07:32 AM UTC

Thank you. This approach requires a crawl of all data.

Perhaps there is an extension that makes the inverse transform before sending data to the server?

Farveen Sulthana Thameeztheen Basha [Syncfusion]
Replied On February 20, 2017 01:14 PM UTC

Hi  Razgovorov, 

Query #1: Remote and Local Data 

While using the above solution to the local Data, it will traverse with the whole datasource. There is no other option. When you bind remote Data to the Grid, it will take only currentPage records. So it won’t affect the performance. 

Query #2:  Transform into timestamp before sending data to the server. 
If you want to transform the date into timestamp before sending data to the server, you can use “actionBegin” event of the grid. In the actionBegin event ,we can get the date in “args.data” and  we have changed the format of date and transform into timestamp by using getTime()  method. 

Please refer to the code example:- 

  <div id="Grid"></div> 
  <script type="text/javascript"> 
        dataSource: new ej.DataManager({ json: data1, adaptor: new dateAdaptor() }), 
        allowPaging: true, 
        editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true }, 
        toolbarSettings: { showToolbar: true, toolbarItems: [ej.Grid.ToolBarItems.Add, ej.Grid.ToolBarItems.Edit, ej.Grid.ToolBarItems.Delete, ej.Grid.ToolBarItems.Update, ej.Grid.ToolBarItems.Cancel] }, 
        columns: [ 
                 { field: "OrderID", headerText: "Order ID", width: 75, textAlign: ej.TextAlign.Right }, 
          { field: "OrderDate", headerText: "Order Date", width: 80, format: "{0:MM-dd-yyyy}", textAlign: ej.TextAlign.Right }, 
        actionBegin: function (args) { 
            if (args.requestType == "save") { 
                var myDate = args.data.OrderDate; 
                myDate = ej.format(new Date(myDate), "MM-dd-yyyy"); 
                myDate1 = myDate.split("-"); 
                var newDate = myDate1[1] + "," + myDate1[0] + "," + myDate1[2]; 
                args.data.OrderDate = new Date(newDate).getTime(); 

Please refer to the attached sample:- 


Otherwise could you please share us the following details to find the cause of the issue.  

1.       Please share us both view and controller side code example. 
2.        Have you bind remote or local data to the Grid. 
       2.     Replication procedure for the issue. 

       3.     Screenshot/Video regarding the issue. 

       4.    If possible, please reproduce the issue in the previously attached sample and send us back. 

       5.    Have you faced any script error regarding this. If so, please share us stacktrace of the issue. 

The provided details will helps us to analyze and provide you solution as early as possible. 


Farveen sulthana T 

Razgovorov Mikhail
Replied On March 8, 2017 06:35 AM UTC

Thanks for the quick and comprehensive answer.
I understood the possibilities.
There is no problem. I'm considering use cases.

Alan Sangeeth S [Syncfusion]
Replied On March 9, 2017 06:43 AM UTC

Hi Razgovorov, 
Thanks for the update. 
Please let us know if you have any other queries. We will be happy to help you. 
Alan Sangeeth S 


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon