-
Hello pplz,
Here i am generating some sort of count down based upon a fixed date (lets say may 15th, as used in the code below)
If i can still do some calculating i should get a result somewhere (counted from this post's entry date March 22) around the 55, but when running this script the result displayed in my swf doesn't go further than 39
is there anyone in the house that can tell me what goes wrong down here......
//-------------CODE--------------------------------
now = new Date();
dateNow = now.getDate();
monthNow = now.getMonth();
daysInMarch = 31;
daysInApril = 30;
daysInMay = 15;
if (monthNow == 1) {
daysLeftInMarch = daysInMarch-dateNow;
daysLeft = daysLeftInMarch+daysInApril+31;
} else if (monthNow == 2) {
daysLeftInApril = daysInApril-dateNow;
daysLeft = daysLeftInApril+31;
} else if (monthNow == 3) {
daysLeftInMay = daysInMay-dateNow;
daysLeft = daysLeftInMay+31;
} else {
daysLeft = 31-dateNow;
}
DateCount = daysLeft;
//----------------CODE-------------------------
Thanx in advance
-
-
when you use .getMonth(); you will receive a number.
0 = january
1 = february
2 = march
3 = april
you have put the wrong numbers in you if-statements.
this code should do the trick
Code:
now = new Date();
dateNow = now.getDate();
monthNow = now.getMonth();
daysInMarch = 31;
daysInApril = 30;
daysInMay = 15;
if (monthNow == 2) {
daysLeftInMarch = daysInMarch-dateNow;
daysLeft = daysLeftInMarch+daysInApril+31;
} else if (monthNow == 3) {
daysLeftInApril = daysInApril-dateNow;
daysLeft = daysLeftInApril+31;
} else if (monthNow == 4) {
daysLeftInMay = daysInMay-dateNow;
daysLeft = daysLeftInMay+31;
} else {
daysLeft = 31-dateNow;
}
DateCount = daysLeft;
-
Originally posted by ^1letser
when you use .getMonth(); you will receive a number.
0 = january
1 = february
2 = march
3 = april
you have put the wrong numbers in you if-statements.
this code should do the trick
Code:
now = new Date();
dateNow = now.getDate();
monthNow = now.getMonth();
daysInMarch = 31;
daysInApril = 30;
daysInMay = 15;
if (monthNow == 2) {
daysLeftInMarch = daysInMarch-dateNow;
daysLeft = daysLeftInMarch+daysInApril+31;
} else if (monthNow == 3) {
daysLeftInApril = daysInApril-dateNow;
daysLeft = daysLeftInApril+31;
} else if (monthNow == 4) {
daysLeftInMay = daysInMay-dateNow;
daysLeft = daysLeftInMay+31;
} else {
daysLeft = 31-dateNow;
}
DateCount = daysLeft;
Thanx ... Those where the enlighting words i was looking for... i did know flash isn't able to count from a zeropoint but i forgot from pure frustration...
Thanx again..
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|