Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
370 views
in Technique[技术] by (71.8m points)

javascript - 用moment.js解析字符串到目前为止(Parse string to date with moment.js)

我想用moment.js 2014-02-27T10:00:00和输出日月份(2014年3月14日)解析以下字符串我一直在阅读文档但没有成功http://momentjs.com/docs/# /分析/现在/

  ask by reachify translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I always seem to find myself landing here only to realize that the title and question are not quite aligned.

(我似乎总是发现自己落在这里只是为了意识到标题和问题并不完全一致。)

If you want a date object from a string :

(如果你想要一个字符串的日期对象 :)

const myDate = moment(str, 'YYYY-MM-DD').toDate();

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...