JavaScript从时间戳获取日期和时间

JavaScript从时间戳获取日期和时间

问题描述:

我将此字段作为网络回复的一部分:

I have this field as part of a web response:

datetime_local: "2015-02-16T19:00:00"

我可以提取日期和时间吗?例如,我想显示

Can I extract the date and time? For instance I would like to display

February 16th at 7pm

这可能吗?

你可以使用 momentjs.com 进行格式化:

You can using momentjs.com for formatting:

moment(Date.parse("2015-02-16T19:00:00")).format("MMMM Do [at] hhA");
// February 16th at 10PM