atatanasov / gijgo

Gijgo - Free Javascript Controls
http://gijgo.com
MIT License
475 stars 188 forks source link

Grid Date Format showing wrong #643

Open itsmegopi opened 4 years ago

itsmegopi commented 4 years ago

I am using below format for displaying date in grid { field: 'openedDate', title: 'Opened Date', sortable: true ,type: 'date', format: ' mm/dd/yyyy' } I have data like below in DB 2020-04-27 19:07:16.4797607 2020-04-27 19:07:16.5765857 2020-04-27 19:07:16.5934191 2020-04-27 19:07:16.6207336 But when it rendered showing wrong values 04/27/2074 04/27/2074 04/27/2074 04/27/2074

Am i am missing anything here or JS has issue ?

eleirbag77 commented 4 years ago

how do you recover data from DB?

itsmegopi commented 4 years ago

Like below grid = $(FormControls.Grid).grid({ primaryKey: 'caseId', dataSource: '/api/Cae/Getcs', uiLibrary: 'bootstrap4', columns: [ .... ], pager: {limit:20, sizes: [20,50,100], } });

VladG1972 commented 4 years ago

.... var renderDateTime = function (value, record, $cell, $displayEl) { var x = new Date(value); if (x.getFullYear() > 1970) $displayEl.text(String(x.getDate()).replace(/^(.)$/, "0$1") + '.' + String(x.getMonth() + 1).replace(/^(.)$/, "0$1") + '.' + x.getFullYear() + ' ' + ("0" + (x.getHours())).slice(-2) + ':' + ("0" + (x.getMinutes())).slice(-2) + ':' + ("0" + (x.getSeconds())).slice(-2)); }; ..... columns: [ .... { field: 'dateLoad', title: 'Дата', type: 'date', width: 150, renderer: renderDateTime }, ... ]