This code snippet you can use to add or subtract minute from JavaScript date object
To add minutes call addMinute method and pass date param in which you want to add the minutesfunction addMinute(date, min) {let nD = new Date(date.getTime() + min * 6e4)return nD;}
To subtract the minute use this method as demonstrate belowlet date = new Date();addMinute(date, 5)
let date = new Date();addMinute(date, -5)
Output:
Comments
Post a Comment