Results 1 to 5 of 5
-
12-27-2004, 03:35 AM #1Aspiring Evangelist
- Join Date
- Aug 2002
- Posts
- 364
need javascript for today's date +2days
hi, i need a javascript for:
show date 2 days in advance
example today is 27 ..than it would display as 29/12/2004 in dd/mm/yy
I have tried out someways..but when today date is 31/12/2004 +2 days would be 33/12/2004 which is not correct.. anyone has a working codes for me?
-
12-27-2004, 04:04 AM #2Web Hosting Master
- Join Date
- Jul 2003
- Location
- Kuwait
- Posts
- 5,104
I'll write out the difficult part -- you can fill in the rest
PHP Code:<script type="text/javascript">
/* Year 2000 bug -- for backwards compatibility */
function y2k(number) {
return (number < 1000) ? number + 1900 : number;
}
function getNextDate(number)
{
var today = new Date();
var thisDay = today.getDate();
var thisMonth = today.getMonth();
var Year = y2k(today.getYear());
/* Days in months */
var days =
new array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
/* Check if we are in a leap year */
if (((Year % 4 == 0) && (Year % 100 != 0)) || (Year % 400 == 0))
days[1] = 29;
else
days[1] = 28;
if (thisDay + number > days[thisMonth - 1])
{
/* The new date will put us in the next month */
} else {
/* The new date is within the current month */
}
}
</script>
-
12-27-2004, 06:54 AM #3Aspiring Evangelist
- Join Date
- Aug 2002
- Posts
- 364
erm so wat else do i have to do to complete it.. i am not quite good but thanks for ur help anyway..any1 can help me with the rest
-
12-27-2004, 12:43 PM #4Aspiring Evangelist
- Join Date
- Aug 2002
- Posts
- 364
any1 can help me pls thanks a lot
-
12-27-2004, 09:00 PM #5Aspiring Evangelist
- Join Date
- Aug 2002
- Posts
- 364
i am kinda stuck can anyone help me with this pls