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

Vivid and natural color which one is better

change the pitch of an audio file using ffmpeg

Steps to deploy the Angular build on Git Hub