javascript - How can I subtract hours and minutes from a HH:MM time string? - Stack Overflow

I have a string realTime = 10:15 and i have subtract 1:20 means(one hours twenty minutes) from string r

I have a string realTime = 10:15 and i have subtract 1:20 means(one hours twenty minutes) from string realTime .

output should be = 8:55.

I am trying something with moment

moment().subtract(realTime , '1:20');

But it's not working, Help me to find the solution. Thanks

I have a string realTime = 10:15 and i have subtract 1:20 means(one hours twenty minutes) from string realTime .

output should be = 8:55.

I am trying something with moment

moment().subtract(realTime , '1:20');

But it's not working, Help me to find the solution. Thanks

Share Improve this question asked Feb 7, 2016 at 18:20 Er KK ChopraEr KK Chopra 1,8508 gold badges33 silver badges57 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 8

It's

moment(realTime, 'HH:mm').subtract(80, 'minutes');

Or, alternatively, you can use moment.duration

var realTime = '10:15';
var duration = moment.duration({hours: 1, minutes: 20})
var sub = moment(realTime, 'HH:mm').subtract(duration).format();

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1743914330a4528914.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信