How to add minutes in javascript date object

 

This code snippet you can use to add or subtract minute from JavaScript date object 

function addMinute(date, min) {
    let nD = new Date(date.getTime() + min * 6e4)
    return nD;
}
To add minutes call addMinute method and pass date param in which you want to add the minutes
    let date = new Date();
    addMinute(date, 5)
To subtract the minute use this method as demonstrate below
    let date = new Date();
    addMinute(date, -5)
Output:

Comments

Popular posts from this blog

change the pitch of an audio file using ffmpeg

Stored procedure that can handle pagination, sorting, and searching based on dynamic columns in Microsoft SQL Server:

Vivid and natural color which one is better