我有一个到期日期和付款日期的发票表。我有第三栏,是从付款日期到到期日期之间的时间。我使用DateTime和格式来计算付款延迟了多少天。
$pDate = date("Y-m-d H:i:s",$paidDate);
$dDate = date("Y-m-d H:i:s",$dueDate);
$pDate = new DateTime($pDate);
$dDate = new DateTime($dDate);
$diff = $pDate->diff($dDate);
$pastDueFormat = $diff->format('%a');
我已尝试将格式更改为
$pastDueFormat = $diff->format('%d');
我在一个由DataTables 格式化的表格中有所有这些数据
$('#invoices').dataTable();
问题是,我无法将39天分类为一个数字,甚至39天。我的排序结果总是
9491988858…
当我清楚地想要94,91,88,85,9,8…
看起来DataTables毕竟不那么智能。您可以显式地提供这样的列类型:
$('#invoices').dataTable({'columnDefs': [{'type': 'num', 'targets': 0}]});
'targets'
键的值应该等于列的索引,从0开始。