[英]Formatting a Date String into a Date
I want to format a string Date "14/06/2019 12:52"
using moment library in order to manipulate a Date object and not a string. 我想使用矩量库设置字符串日期"14/06/2019 12:52"
格式,以便操作日期对象而不是字符串。
I tried using moment library but didn't succeed to have a Date object 我尝试使用矩型库,但未成功拥有Date对象
const myDate = moment('14-06-2019 12:52')
the const myDate
is not of type Date. const myDate
不是日期类型。
您还需要提供格式
const myDate = moment('14-06-2019 12:52', 'DD-MM-YYYY hh:mm');
You could use moment().toDate();
您可以使用moment().toDate();
Refer here for more info http://momentjs.com/docs/#/displaying/as-javascript-date/ 有关更多信息,请参见此处http://momentjs.com/docs/#/displaying/as-javascript-date/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.