admin管理员组文章数量:1429841
I have an ISO-8601 date of the form:
2014-02-02T15:00:00-0800
Can anyone demonstrate how to to extract a time of the form
3:00pm
Using moment.js
I have an ISO-8601 date of the form:
2014-02-02T15:00:00-0800
Can anyone demonstrate how to to extract a time of the form
3:00pm
Using moment.js
Share Improve this question asked Jan 20, 2014 at 22:45 Ben PearceBen Pearce 7,10419 gold badges76 silver badges129 bronze badges 3- possible duplicate of Help parsing ISO 8601 date in Javascript – SOReader Commented Jan 20, 2014 at 22:49
- There's no moment.js solution in the referenced question. – Ben Pearce Commented Jan 20, 2014 at 23:04
- 1 have you checked the moment.js documentation? – jeremy Commented Jan 21, 2014 at 0:46
1 Answer
Reset to default 3Here you find Parse
documentation. Here is Format
. Combined together gives:
var dateAsString = '...';
moment.utc(dateAsString).format('h:mmA');
http://jsfiddle/76Ued/1/
http://jsfiddle/76Ued/2/ <- this one uses local()
EDIT
Version considering Matt Johnson's hint:
var dateAsString = '...';
moment(dateAsString).format('h:mmA');
http://jsfiddle/76Ued/13/
版权声明:本文标题:javascript - Parsing a human readable time from an ISO-8601 formatted string using moment.js - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745486920a2660425.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论