# Date problem

**URL:** <https://forum.kirupa.com/t/date-problem/186004>\
**Category:** Uncategorized\
**Created:** [April 18, 2006, 12:05pm UTC](https://forum.kirupa.com/t/date-problem/186004 "2006-04-18T12:05:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![magneto\_ms](https://avatars.discourse-cdn.com/v4/letter/m/ce73a5/32.png) [@magneto\_ms](https://forum.kirupa.com/u/magneto_ms)\
**Post date:** [April 18, 2006, 12:05pm UTC](https://forum.kirupa.com/t/date-problem/186004/1 "2006-04-18T12:05:37Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![theHollow](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/thehollow/32/106_2.png) [@theHollow](https://forum.kirupa.com/u/theHollow)\
**Post date:** [April 18, 2006, 1:09pm UTC](https://forum.kirupa.com/t/date-problem/186004/2 "2006-04-18T13:09:30Z")

</div>

Just copy and paste the following, its pretty straightforward

```auto
// 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);

```

---

<div class="post-metadata">

**Author:** ![magneto\_ms](https://avatars.discourse-cdn.com/v4/letter/m/ce73a5/32.png) [@magneto\_ms](https://forum.kirupa.com/u/magneto_ms)\
**Post date:** [April 18, 2006, 2:10pm UTC](https://forum.kirupa.com/t/date-problem/186004/3 "2006-04-18T14:10:38Z")

</div>

Worked like a charm!:pleased:

Thanks!:flower:
