I am developing a report system. In my report system I am going to automatically plus days to date that picked date. I used following Javascript code snippet.
function add_date(curdate, days) {
//curdate format : "yyyy-mm-dd"
var newdate = new Date(curdate);
newdate.setDate(newdate.getDate() + days);
var dd = newdate.getDate();
var mm = newdate.getMonth() + 1;
var y = newdate.getFullYear();
if(dd < 10)
dd = '0' + dd;
if(mm < 10)
mm = '0' + mm;
var someFormattedDate = y + '-' + mm + '-' + dd;
return someFormattedDate;
}
This function is working as well on almost platforms and browsers. But on the particular platform or browser like iPhone Safari and Windows 8.1, I got different result. If I plus 3 days, I can get the result that plus 2 days. I tested on my computer, iPhone and browserstack.com. I want kindly your assistance. Thanks.