Sorting for format (Y-m-d H:i:s) is not working
Sorting for format (Y-m-d H:i:s) is not working
Greetings all,
I have a problem with sorting a date column.
My date is in this format
[code]Y-m-d H:i:s[/code]
And I am getting this output:
[code]
2012-04-14 23:07:00
2012-01-14 22:40:14
2012-03-09 19:03:20
2012-03-12 16:00:28
2012-05-01 16:09:38
2012-02-11 05:07:08
2012-01-17 15:15:09
2012-03-10 16:02:20
2012-02-09 14:33:19
[/code]
This is my initialization:
[code]
$(document).ready(function() {
oTable=$('#jphit').dataTable( {
"sDom": 'T,C<"clear">lfrtip',
"oTableTools": {
"sSwfPath": "swf/copy_csv_xls_pdf.swf"
},
"oColVis": {
"buttonText": "Extend table",
"activate": "mouseover"
},
"aoColumnDefs": [
{ "bVisible": false, "aTargets": [ 2 , 4 , 6] }
],
"aoColumns": [
{
"mDataProp": null,
"sClass":"center",
"sDefaultContent": ''
},
{ "mDataProp": 0 }, //date column
{ "mDataProp": 1 },
{ "mDataProp": 2 },
{ "mDataProp": 3 },
{ "mDataProp": 4 },
{ "mDataProp": 5 },
{ "mDataProp": 6 }
],
"aaSorting": [[0,'desc']], //sort date column
"bProcessing": true,
"bSort": true,
"sPaginationType": "full_numbers",
"bServerSide": true,
"sScrollY": "500px",
"bDeferRender": true,
"sAjaxSource": "history_table.php"
} );
[/code]
This is my PHP part:
[code]
$aRow[$iTimestampCol] = date( 'Y-m-d H:i:s', $aRow[$iTimestampCol] );
[/code]
My date variable is in UNIX timestamp so with this line I am converting it into the normal datetime variable.
Can someone please point me in the right direction? What could be the problem? Is this correct format to use sorting? If not in which format should I convert to?
Thank you!
I have a problem with sorting a date column.
My date is in this format
[code]Y-m-d H:i:s[/code]
And I am getting this output:
[code]
2012-04-14 23:07:00
2012-01-14 22:40:14
2012-03-09 19:03:20
2012-03-12 16:00:28
2012-05-01 16:09:38
2012-02-11 05:07:08
2012-01-17 15:15:09
2012-03-10 16:02:20
2012-02-09 14:33:19
[/code]
This is my initialization:
[code]
$(document).ready(function() {
oTable=$('#jphit').dataTable( {
"sDom": 'T,C<"clear">lfrtip',
"oTableTools": {
"sSwfPath": "swf/copy_csv_xls_pdf.swf"
},
"oColVis": {
"buttonText": "Extend table",
"activate": "mouseover"
},
"aoColumnDefs": [
{ "bVisible": false, "aTargets": [ 2 , 4 , 6] }
],
"aoColumns": [
{
"mDataProp": null,
"sClass":"center",
"sDefaultContent": ''
},
{ "mDataProp": 0 }, //date column
{ "mDataProp": 1 },
{ "mDataProp": 2 },
{ "mDataProp": 3 },
{ "mDataProp": 4 },
{ "mDataProp": 5 },
{ "mDataProp": 6 }
],
"aaSorting": [[0,'desc']], //sort date column
"bProcessing": true,
"bSort": true,
"sPaginationType": "full_numbers",
"bServerSide": true,
"sScrollY": "500px",
"bDeferRender": true,
"sAjaxSource": "history_table.php"
} );
[/code]
This is my PHP part:
[code]
$aRow[$iTimestampCol] = date( 'Y-m-d H:i:s', $aRow[$iTimestampCol] );
[/code]
My date variable is in UNIX timestamp so with this line I am converting it into the normal datetime variable.
Can someone please point me in the right direction? What could be the problem? Is this correct format to use sorting? If not in which format should I convert to?
Thank you!
This discussion has been closed.
Replies
Allan