Menus

Thursday 7 December 2017

Javascript Tutorials


Convert DD-MM-YYYY to YYYY-MM-DD format using Javascript



var date = "03-11-2014"; 
var newdate = date.split("-").reverse().join("-");



Javascript add number of days to today's date?



   var dd = 07-12-2017
   var x = 30; //days for add 

   var newdate = dd.split("-").reverse().join("-");   //date convert yyyy-mm-dd
   var someDate = new Date(newdate);
   someDate.setDate(someDate.getDate() + x); //number  of days to add, e.x. x days
   var dateFormated = someDate.toISOString().substr(0,10);     
          
   var vdate = dateFormated.split("-").reverse().join("-");   //date convert to dd-mm-yyyy  
 
 




No comments:

Post a Comment