I have the following code to convert a long date format in JavaScript to mm/dd/yyyy. When newValu is "Date 2016-12-29T00:00:00.000Z" from console log, date_str go back one day, becomes "12/28/2016". Not sure what is causing the problem. If we increment the d (day) by 1, that will not work, because we might need to increment the month instead, if d = 31.
console.log(newValue);
var date = newValue;
var d = date.getDate();
var m = date.getMonth() + 1;
var y = date.getFullYear();
date_str = (m<=9 ? '0' + m : m) + '/' + (d <= 9 ? '0' + d : d) + "/" + y;