Convert DD-MM-YYYY to YYYY-MM-DD format using Javascript
var newdate = date.split("-").reverse().join("-");
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
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