用moment.js解析字符串到目前为止 [英] Parse string to date with moment.js
本文介绍了用moment.js解析字符串到目前为止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想用moment.js解析以下字符串 2014-02-27T10:00:00 并输出
每月(2014年3月14日)
我有一直在阅读文档,但没有成功
http://momentjs.com/docs/#/parsing/now/
I want to parse the following string with moment.js 2014-02-27T10:00:00 and output day month year (14 march 2014) I have been reading the docs but without success http://momentjs.com/docs/#/parsing/now/
推荐答案
您需要使用 .format()
功能。
MM
- 月份数
MMM
- 月字
var date = moment("2014-02-27T10:00:00").format('DD-MM-YYYY');
var dateMonthAsWord = moment("2014-02-27T10:00:00").format('DD-MMM-YYYY');
FIDDLE
这篇关于用moment.js解析字符串到目前为止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文