Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org

Feedback: irt.org FAQ Knowledge Base Q1773

Feedback on: irt.org FAQ Knowledge Base Q1773

Sent by Rahul on Wednesday August 01, 2007 at 07:28:22 - feedback #4868

Worth:
Worth reading

Length:

Technical:

Comments:
Hi,

It is very usefull script but still some problem is there.
when any end of month come in between start and ened day. it calculates wrong end date.
just check it with this.
document.write(days_between('31-08-2007', 3))
>>>> returns 4/9/2007 = wrong
document.write(days_between('31-08-2007', 4))
>>>> returns 5/9/2007 = wrong
document.write(days_between('02-08-2007', 2))
>>>> returns 3/8/2007 = right






Sent by bela on Tuesday September 11, 2007 at 16:26:07 - feedback #5013

Worth:
Worth reading

Length:

Technical:

Comments:
function calculateDate(date1, days) {//calculate a date base on vdate+days. Date format is YYYYMMDD
var old_date = new Date(date1.substring(0, 4), parseInt(date1.substring(4, 6) - 1), date1.substring(6, 8));

var one_day = 24*60*60*1000;

alert(old_date.getTime());

var new_date = new Date(old_date.getTime()+(24*60*60*1000)*days);

var new_m = new_date.getMonth() + 1;
if (new_m > 9) m= '' + new_m;
else m = '0' + new_m;

var new_d = new_date.getDate();
if (new_d > 9) d= '' + new_d;
else d = '0' + new_d;

alert(new_date.getFullYear() + m + d);
return new_date.getFullYear() + m + d;

}




©2018 Martin Webb