如何在JavaScript中向HH:MM:SS添加分钟? 由 yeum发布于 2020-05-24 04:29:05 stringjavascriptdatetimedatetime-conversion 收藏 我想将分钟(typeof Integer)添加到HH:MM:SS(typeof String)。 例: let min = 125; let time = "10:00:00"; 结果=“ 12:05:00” 评论 请 登录后发表观点 gomnis 2020-05-24 04:29:06 Make a new Date object and then set the time with setHours(). let time = new Date(); // pass hours, minutes, seconds and account for local time zone // I'm GMT-4 so I pass 16 to get to 20 time.setHours(16,5,0); console.log(time); 点赞 评论 到底啦
Make a new Date object and then set the time with
setHours()
.