![](/img/trans.png)
[英]How to convert timestamp firestore to date string and display in antd table
[英]Antd table, how to sort by date including the whole timestamp?
我有這個項目
const data: Item[] = [
{
key: 1,
name: 'John Brown',
date: moment('10-10-2019').format('L'),
address: 'New York No. 1 Lake Park',
},
{
key: 2,
name: 'Joe Black',
date: moment('11-10-2019').format('L'),
address: 'London No. 1 Lake Park',
},
{
key: 3,
name: 'Jim Green',
date: moment('7-10-2019').format('L'),
address: 'Sidney No. 1 Lake Park',
},
{
key: 4,
name: 'Jim Red',
date: moment('8-10-2019 8:00 PM').format('L'),
// date: moment('8-10-2019 8:00 PM').format('MMMM Do YYYY, h:mm:ss a'),
address: 'London No. 2 Lake Park',
},
];
如果我將該數據用於“日期”,並且我使用以下排序器,則它可以正常工作
sorter: (a, b) => moment(a.date).unix() - moment(b.date).unix()
但我希望數據更復雜一點,像這樣
date: moment('8-10-2019 8:00 PM').format('MMMM Do YYYY, h:mm:ss a')
其中評估為August 10th 2019, 8:00:00 pm
問題是,我無法使用上述排序器對數據進行排序。 我怎么能做到?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.