javascript - 如何在 React js 中格式化日期
问题描述
我正在使用 React Date Picker 获取日期,截至目前,我收到的日期为:Fri Feb 01 2019 00:00:00 GMT+0530(印度标准时间),现在我想将其格式化为“”YYYY- MM-DD" 格式。有没有办法在 React js 中实现这一点?
我尝试这样做但没有帮助:
date=this.state.startDate.getDate() + "-"+ parseInt(this.state.startDate.getMonth()+1) +"-"+this.state.startDate.getFullYear();
解决方案
推荐阅读
- java - 使用休眠将一行插入数据库,我将“1”和空值放入数据库而不是用户输入的值
- java - Scanner 采用用户输入的整数,然后采用字符串数组,但跳过第一个输入的字符串
- python - “模型”对象没有属性“损失函数”
- php - 每当值 x 比值 y 模 3 大 1 时进行测试
- docker - 无法将 Docker CLI 连接到本地 Docker 守护程序
- reactjs - react-popper 错位 popper 元素
- google-apps-script - Google 表格:是否有 RETRY(FORMULA(), amount_of_retries) 公式?
- java - 从 json 到列表的格式是什么?
- encryption - 如何在 C# 中从内存中删除加密密钥?
- python - 为什么 ubuntu 最终会使用不同版本的 python 和 pip 并且 django 被全局安装而不是在 virtualenv 中?