hello, i am pretty new to flash. I been making my portfolio. The thing is that i need to upload some ‘daily content’ on my site.
Is there anyway of getting the number of the current day in an year…?
For eg: For February 13th I want the number 44 to be displayed.(44=31+13)
Can you help…?
Thanx.
Just copy and paste the following, its pretty straightforward
// Tests if the current year is a leap year
// and returns the correct amount of days
getDaysInYear = function(year:Number):Number {
if (year % 4 == 0) {
daysInMonth[1] = 29; // Sets the days in february
return 366;
} else {
daysInMonth[1] = 28; // Sets the days in february
return 365;
}
};
// Finds the current day in the year
getCurrentDay = function(month:Number):Number {
var temp:Number = 0;
for (i = 0; i < month; i++) {
temp += daysInMonth*;
}
return temp + myDate.getDate();
};
var myDate:Date = new Date(); // Date Object
// Days in each month
var daysInMonth:Array = [31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
var year:Number = myDate.getFullYear(); // Current year (20## format)
var daysInYear:Number = getDaysInYear(year); // Days in the current year
var currentDay:Number = getCurrentDay(myDate.getMonth()); // The current day
trace(currentDay);
Worked like a charm!:pleased:
Thanks!:flower: