Skip to content
Loading
  • +2
    Show your function and the actual error
    +2
  • Jay Krishna Reddy
    +2
    1. var dt = new Date();  
    2. dt.setMinutes(dt.getMinutes() + 30);  
    3. console.log(dt);  
    You can use like this to add minutes to date.
    +2
  • Shivangi Rajde
    +2
    Hello,
     
    I have created a function that takes the input as number of minutes to be added to the date. You can try this code
    1. var date = new Date();   
    2. var datetime = date.getDate() + "/"  
    3.                 + (date.getMonth()+1)  + "/"   
    4.                 + date.getFullYear() + " @ "    
    5.                 + date.getHours() + ":"    
    6.                 + date.getMinutes() + ":"   
    7.                 + date.getSeconds();  
    8.   
    9. // Pass the number of minutes that you want to add in the function as parameter               
    10. function add_minutes(min){                
    11.     date.setMinutes(date.getMinutes()+min)  
    12. }  
    13. // I have added 30 minutes to my date  
    14. add_minutes(30);  
    15. console.log("Date with added minutes: ", date);  
     
    Hope this helps!
    +2