[英]How to format datetime using react-moment library
I want to format date and time by having string value.我想通过具有字符串值来格式化日期和时间。 Therefore, I want my property to hold a formatted date and time using a library react-moment and return the local time.因此,我希望我的属性使用库 react-moment 保存格式化的日期和时间并返回本地时间。 All this must be a function which I'll callback in my table.所有这些都必须是我将在我的表中回调的函数。 How could I make this?我怎么能做到这一点?
import * as React from 'react';
type Props = {
value: string;
};
const DateTimeColumn = (props: Props) => {
const { value } = props;
// TODO:
}
You can simply return the converted date like so:您可以简单地返回转换后的日期,如下所示:
import Moment from 'react-moment';
const DateTimeColumn = (props: Props) => {
const { value } = props;
return (
<Moment format="YYYY/MM/DD" date={value} />
)
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.