admin管理员组文章数量:1432573
I wonder if it is possible to fetch hours, minutes and seconds from Moment object?
for example:
Moment('12:16','HH:mm').get('minutes') //should result in '16'
I can't find anything like that in documentation though...
I wonder if it is possible to fetch hours, minutes and seconds from Moment object?
for example:
Moment('12:16','HH:mm').get('minutes') //should result in '16'
I can't find anything like that in documentation though...
Share Improve this question asked Nov 18, 2019 at 10:47 janlanjanlan 4771 gold badge5 silver badges21 bronze badges 1- moment().minutes(); // Number – Jayakumar Thangavel Commented Nov 18, 2019 at 10:51
2 Answers
Reset to default 16Please try the following:-
Moment('12:16','HH:mm').minutes();
UPDATE:
Second option here - use format('mm')
. It will return '16'
in a string format.
Moment.js has documented minutes()
function in link.
P.S. A piece of advice for the future - be more detailed in your question. Probably, you have some use-case in your code that you want to solve. In case if people have a description of your case they could help you to solve you case maybe in a more elegant way.
Have a nice day! Be kind and mark the answer that was useful for you as the right one!
moment().minute(); // Number
moment().seconds(); // Number
Document : https://momentjs.com/docs/#/get-set/minute/
var now = moment().minutes();
alert(now);
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.20.1/moment.min.js"></script>
本文标签: javascriptGet hoursminutesseconds from Momentjs objectStack Overflow
版权声明:本文标题:javascript - Get hours, minutes, seconds from Moment.js object - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738553034a2097742.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论