javascript - 是否可以在对象内格式化日期?
问题描述
这样的事情可能吗?尝试格式化日期formatted_short
<Generic type="startDate" jsonldtype="DateTime" schema={{
startDate: `${props.dates[0].start_date.formatted_short.format('YYYY-MM-DD')}`,
endDate: `${props.dates[0].end_date.formatted_short}`,
doorTime: `${props.dates[0].start_date.time}`,
}}/>
解决方案
您可以使用 react-moment 格式化日期。
你可以这样使用;
import React from 'react';
import Moment from 'react-moment';
export default class MyComponent extends React.Component {
render() {
return (
// format : your format.
<Moment format="YYYY/MM/DD">
1976-04-19T12:59-0500 // your date string
</Moment>
);
}
}
推荐阅读
- c# - if 语句中的 EulerAngles Unity 不适用于某些值 C#
- mysql - mysql选择MAX但显示不符合预期
- automated-tests - Windows 桌面应用程序测试自动化的 Gherkin 语法
- php - 在 PHP 中向 API 发送数据
- angular - 如何正确查看路由器的历史
- python - 匀称的多边形按Python顺序相交
- javascript - jQuery删除多个样式
- python - 查找最接近输入的行值
- node.js - 如何使用 Google App Engine node.js 运行时设置 Datadog?
- ubuntu - Vagrant SSH 没有这样的文件或目录