my sql database table column is with datetime datatype ..
my datatable column with type date :
{
"label": "Created On",
"name": "CreatedOn",
"type": "date",
"dateFormat": "yy-mm-dd"
}
when retrieving data from my server, the data table column must shows the proper datetime format .. but it never occurred it always shows a strange data value looks like this : /Date(1390687200000)/
Please provide a test case as explained in the link:
http://www.datatables.net/forums/discussion/12899/post-test-cases-when-asking-for-help-please-read
Looks like an epoch timestamp in milliseconds to me (seconds since 1st Jan 1970) - but it might be something else.
You will need to format the date into something readable using DATE_FORMAT or whatever SQL function is appropriate for your database. Editor's PHP libraries have date formatting options built in, how you do it using other scripts will depend entirely on how those scripts work.
Hi, just wanted to post my solution. I get this too, for from my source I select datetime from a mssql database. If you look with fiddler (a great tool for seeing what happens) you see the JSON has this format you get. If you look in the code in visual studio express and capture what you got before passing it to JSON you see something like "{12/12/2012 12:12}". So actually the cause is the JSON.
My solution was to put this piece of code in the specific column in the datatable definition
[code]"mRender": function (data, type, full) {
var dtStart = new Date(parseInt(data.substr(6)));
var dtStartWrapper = moment(dtStart);
return dtStartWrapper.format('DD/MM/YYYY HH:mm');
}
[/code]
Replies
http://www.datatables.net/forums/discussion/12899/post-test-cases-when-asking-for-help-please-read
my sql database table column is with datetime datatype ..
my datatable column with type date :
{
"label": "Created On",
"name": "CreatedOn",
"type": "date",
"dateFormat": "yy-mm-dd"
}
when retrieving data from my server, the data table column must shows the proper datetime format .. but it never occurred it always shows a strange data value looks like this : /Date(1390687200000)/
http://www.datatables.net/forums/discussion/12899/post-test-cases-when-asking-for-help-please-read
Looks like an epoch timestamp in milliseconds to me (seconds since 1st Jan 1970) - but it might be something else.
You will need to format the date into something readable using DATE_FORMAT or whatever SQL function is appropriate for your database. Editor's PHP libraries have date formatting options built in, how you do it using other scripts will depend entirely on how those scripts work.
Allan
My solution was to put this piece of code in the specific column in the datatable definition
[code]"mRender": function (data, type, full) {
var dtStart = new Date(parseInt(data.substr(6)));
var dtStartWrapper = moment(dtStart);
return dtStartWrapper.format('DD/MM/YYYY HH:mm');
}
[/code]
Please note my site already uses moment.js