Reactjs 如何使用react矩库格式化datetime

Reactjs 如何使用react矩库格式化datetime,reactjs,Reactjs,我想用字符串值格式化日期和时间。因此,我希望我的属性使用库react time保存格式化的日期和时间,并返回本地时间。所有这些都必须是一个函数,我将在我的表中回调它。我怎么做这个 import * as React from 'react'; type Props = { value: string; }; const DateTimeColumn = (props: Props) => { const { value } = props; // TODO:

我想用字符串值格式化日期和时间。因此,我希望我的属性使用库react time保存格式化的日期和时间,并返回本地时间。所有这些都必须是一个函数,我将在我的表中回调它。我怎么做这个


import * as React from 'react';

type Props = {
    value: string;
};

const DateTimeColumn = (props: Props) => {
    const { value } = props;
    // TODO:
}

您只需返回转换后的日期,如下所示:

import Moment from 'react-moment';

const DateTimeColumn = (props: Props) => {
    const { value } = props;
    return (
       <Moment format="YYYY/MM/DD" date={value} />
    )
}
从“反应力矩”导入力矩;
const DateTimeColumn=(props:props)=>{
常量{value}=props;
返回(
)
}

在我看来,不太清楚你在问什么。我的猜测是,您有一个UTC-0格式的日期-时间字符串,您需要一个组件来接收该日期-时间字符串并将其显示在用户的时区中。
返回值?力矩(值)。格式('LLL'):null