本文介绍了如何添加20分钟到当前日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以得到这样的当前日期对象:

I can get the current date object like this:

var currentDate = new Date();

如何添加20分钟?

var twentyMinutesLater = ?;


推荐答案

使用获取当前分钟,然后添加20并使用来更新日期对象。

Use .getMinutes() to get the current minutes, then add 20 and use .setMinutes() to update the date object.

var twentyMinutesLater = new Date();
twentyMinutesLater.setMinutes(twentyMinutesLater.getMinutes() + 20);

这篇关于如何添加20分钟到当前日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-12 10:26