Posted tagged ‘JavaScript’

Add minutes to date in JavaScript

November 3, 2010

 

Here is a quick snippet to add minutes to a date in JavaScript.  A similar technique can be used for hours, seconds, etc.

var minutesToAdd = 10;

var someDate = new Date();
someDate.setMinutes(someDate.getMinutes() + minutesToAdd);

Keeping the original date

var someDate = new Date();
var adjustedDate = new Date(someDate);
adjustedDate.setMinutes(someDate.getMinutes() + minutesToAdd);