react 我有这样的代码:
 

184       {
185         title: '创建时间',
186         dataIndex: 'created_at',
187         key: 'created_at',
188         render: (text) => new Date(text).toLocaleString('zh-CN', { timeZone: 'Asia/Shanghai' }),
189       },

显示的时间的格式是:
2023/8/15 16:46:41

我想得到用-连接的时间,例如 2023-08-15 16:46:41,使用:

{
title: '创建时间',
dataIndex: 'created_at',
key: 'created_at',
render: (text) => {
const formattedDate = new Date(text).toLocaleString('zh-CN', { timeZone: 'Asia/Shanghai' });
const formattedDateWithDash = formattedDate.replace(/\//g, '-');
return formattedDateWithDash;
},
},