-
Hi all,
I'm trying to use Flash 5 to display how old my web site is - in other words, take the start date (April 8, 1998) and display how old it is ("Floor 42 is x years, x months, x days old". The searches I did on the forums showed me how to count down a date, but trying to apply that logic to counting UP a date has left my math-impaired brain a little stuck.
I've done what probably amounts to a ridiculous amount of code to get the year and month, but I can't for the life of me figure out how to get the days. If you could take a look at the code below and let me know if there's an easier way to do it, and if you have a solution for the days, I'd be much obliged:
Code:
theDate = new Date();
f42Date = new Date(1998, 3, 8);
dater = theDate.getDate();
realYear = theDate.getFullYear();
f42Year = f42Date.getFullYear();
fdays = 8-dater;
// how many years old is Floor 42?
if (realMonth<3) {
// if it is before April
f42YearsOld = (realYear-f42year)-1;
} else if (realMonth=3) {
if (dater<8) {
// if it is before the 8th
f42YearsOld = (realYear-f42year)-1;
} else {
f42YearsOld = (realYear-f42year);
}
} else {
f42YearsOld = (realYear-f42year);
}
// how many months old is Floor 42?
realMonth = theDate.getMonth();
if (realMonth < 3) {
fmonths = realMonth + 9;
} else if (realMonth >= 4) {
fmonths = realMonth - 3;
} else {
if (dater<8) {
// if it is before the 8th
fmonths = 11;
} else {
fmonths = 0;
}
}
// how many days? this code doesn't work at all! brain freeze!
f42TotalDays = 365 * f42YearsOld; // gave up on that
f42DaysOld = (30 - dater) - 8; // not sure what I was thinking with this
// output
floorCount = "Floor 42 is "+f42YearsOld+" years, "+fmonths+" months, "+f42DaysOld+" days old"
Ridicule the newly converted Flash 5 user at will ;)
-- and thank you for any help!!!
Best,
Kate
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
|