本文主要是介绍js moment计算当前时间到24:00:00的剩余时间,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
2023.12.7今天我学习了如何计算当前的时间到24:00:00剩下的时间,
https://momentjs.cn/
const now = moment(); // 获取当前时间const endOfDay = moment().endOf('day'); // 设置当天的 23:59:59const duration = moment.duration(endOfDay.diff(now)); // 计算剩余时间的 Duration 对象// 获取剩余时间的小时、分钟和秒钟const hours = duration.hours();const minutes = duration.minutes();const seconds = duration.seconds();console.log(hours + ':' + minutes + ':' + seconds); // 输出剩余时间
这篇关于js moment计算当前时间到24:00:00的剩余时间的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!