簡體   English   中英

如何使用反應時刻庫格式化日期時間

[英]How to format datetime using react-moment library

我想通過具有字符串值來格式化日期和時間。 因此,我希望我的屬性使用庫 react-moment 保存格式化的日期和時間並返回本地時間。 所有這些都必須是我將在我的表中回調的函數。 我怎么能做到這一點?


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} />
    )
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM