How to get year/month/day from a date object?

var dateObj = new Date();
var month = dateObj.getUTCMonth() + 1; //months from 1-12
var day = dateObj.getUTCDate();
var year = dateObj.getUTCFullYear();

newdate = year + "https://stackoverflow.com/" + month + "https://stackoverflow.com/" + day;

or you can set new date and give the above values

Leave a Comment