更新时间:2023-01-31 14:49:44
无需修改原始字符串,您可以这样使用:
alert(moment(2013-06-13T16:29:55.245Z)。format(M / DD / YYYY));
效果很好: http://jsfiddle.net/K5ub8/2/
I am trying to reformat a date that I am getting from an API. In the object I have:
created_at: "2013-06-13T16:29:55.245Z"
I would like to display the date as 6/13/2013. Someone suggested I use moment.js. It has tons of documentation but i'm a bit confused on how to use it. can someone please help or suggest an easier way to do this?
No need to modify the original string, you can just use it like this:
alert(moment("2013-06-13T16:29:55.245Z").format("M/DD/YYYY"));
Works well: http://jsfiddle.net/K5ub8/2/