I have a datatable with a few columns. One column is a timestamp with seconds for example 9/8/21 8:06:10 PM. When I export the data to a csv file, the seconds are truncated that is 10 is not showing up in the file. Is there any way to specify the format of the timestamp in the csv file when exporting?
dom: '<lBfrtip>',
buttons: [
{ extend: 'csv' },
]
You can try formatting function on that field when exporting. From the docs I adapted this code:
buttons: [{
extend: 'csv',
exportOptions: {
format: {
body: function(data, row, column, node) {
// return cast to string if column #5 ?
return column === 5 ? ("" + data) : data;
}
}
},
]