![](/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.