-------

-------

  • 1.8k
  • 212
  • 2.6k

datatable time is different from database time

Nov 28 2020 4:57 AM
eI am trying to show database time in the datatable but issue is show the current time
 
see database time
 
 
 
see datatable time 
 
 
.cshtml
  1. $.ajax({  
  2.                 url: strUrl,  
  3.                 type: 'POST',  
  4.                 success: function (result) {  
  5.                       
  6.                     console.log("inside the success method")  
  7.                     $('#').DataTable({  
  8.                         data: result,  
  9.                         columns: [  
  10.                             { data: "StartFromTime" },  
  11.                             { data: "EndToTime" },  
  12.                              
  13.                         ],  
  14.   
  15.                         "aoColumnDefs": [  
  16.                               {  
  17.                                   "aTargets": [0],  
  18.                                   //title: "StartFromTime",  
  19.                                   "mRender": function (row) {//data  
  20.                                       //console.log("inside the date and time:" + data + ":" + type);  
  21.                                       //console.log(moment(row.StartFromTime).format('DD/MM/YYYY hh:mm:ss'));  
  22.                                       //console.log("StartFromTime:" +moment(row.StartFromTime).format('hh:mm:ss'));  
  23.                                       //console.log("innnn");  
  24.                                       //console.log(row);  
  25.                                       ////console.log(data);  
  26.                                       //console.log(type);  
  27.                                       //console.log(moment(row).format('hh:mm:ss'));  
  28.                                       //var date = new Date(parseInt(data.substr(6)));  
  29.                                       //console.log("date:" + date);  
  30.                                       //return date.getDate();  
  31.                                       return moment(row.StartFromTime).format('hh:mm:ss');  
  32.   
  33.                                   }  
  34.                               },  
  35.                               {  
  36.                                   "aTargets": [1],  
  37.                                  
  38.                                   "mRender": function (row) {//data  
  39.                                       return moment(row.EndToTime).format('hh:mm:ss');  
  40.   
  41.                                   }  
  42.                               },  
model
 
  1. public class TimeList  
  2. {  
  3.     public int Id { get; set; }  
  4.     public DateTime StartFromTime { get; set; }  
  5.     public DateTime EndToTime { get; set; }  
how to show the database time in datatable?
 
problem is moment() is built in jquery function that is the reason show the current time I want to show database time
 
I want to show database time in datatable? 
 
 
 

Answers (12)