I am using date-format package in node back end and I can get today date using
var today = dateFormat(new Date());
In the same
To get the string in a format familiar to people
// Date String returned in format yyyy-mm-dd
function getYesterdayString(){
var date = new Date();
date.setDate(date.getDate() - 1);
var day = ("0" + date.getDate()).slice(-2);
var month = ("0" + (date.getMonth() + 1)).slice(-2); // fix 0 index
return (date.getYear() + 1900) + '-' + month + '-' + day;
}
you can also change Hour,Minute,seconds and milliseconds attributes of time object like this.
var date = new Date();
date.setDate(date.getDate()-1);
date.setHours(hour);
date.setMinutes(minute);
date.setSeconds(seconds);
date.setMilliseconds(milliseconds);