Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 06-15-2005, 07:37 AM   #1
webreake
Senior Member
 
Join Date: Oct 2003
Location: mexico
Posts: 214
Send a message via MSN to webreake Send a message via Skype™ to webreake
Default get days of a month

hi
im getting a problem when i try to get the days of a month here is my function:
ActionScript Code:
function days(year, month) {     var thisMonth = new Date(year, month);     var nextMonth = new Date(year, month+1);     var Ndays = ((((nextMonth-thisMonth)/1000)/60)/60)/24;     return Ndays; }

in september and november i get 31 days
I didnt try yet the Math.round but i want to know if
there is a better way to do this ?
webreake is offline   Reply With Quote
Old 06-15-2005, 02:06 PM   #2
tg
done
 
Join Date: Jun 2001
Location: portland, or
Posts: 8,106
Default

http://proto.layer51.com/d.aspx?f=1322
__________________
tg
---
what the hell was i thinking?
tg is offline   Reply With Quote
Old 06-15-2005, 02:26 PM   #3
jsebrech
Joeri Sebrechts
 
Join Date: Apr 2005
Location: Antwerp, Belgium
Posts: 1,465
Default

Beware that the month variable to date functions (like new Date()) starts from 0, so january is 0, februrary is 1, and so on.
jsebrech is offline   Reply With Quote
Old 06-15-2005, 07:39 PM   #4
webreake
Senior Member
 
Join Date: Oct 2003
Location: mexico
Posts: 214
Send a message via MSN to webreake Send a message via Skype™ to webreake
Default

thanks for the answers
the method works great
webreake is offline   Reply With Quote
Old 02-03-2009, 09:07 AM   #5
flashDuniya
Registered User
 
Join Date: Jan 2009
Posts: 10
Default Number of days in a month

Quote:
Originally Posted by webreake View Post
hi
im getting a problem when i try to get the days of a month here is my function:
ActionScript Code:
function days(year, month) {     var thisMonth = new Date(year, month);     var nextMonth = new Date(year, month+1);     var Ndays = ((((nextMonth-thisMonth)/1000)/60)/60)/24;     return Ndays; }

in september and november i get 31 days
I didnt try yet the Math.round but i want to know if
there is a better way to do this ?
This is the very simple code to find the number of days in a month

function showDays(yr, mn){
var daysate = new Date(yr, mn+1, 0);
trace(days.date);// It will trace total no. of days(28) in a month
}
showDays(2009, 1);// 1=February

Thanks,
flashDuya.com
flashDuniya is offline   Reply With Quote
Old 08-13-2010, 02:54 PM   #6
peptobismol
Senior Member
 
Join Date: Oct 2005
Posts: 746
Default

Quote:
Originally Posted by flashDuniya View Post
This is the very simple code to find the number of days in a month

function showDays(yr, mn){
var daysate = new Date(yr, mn+1, 0);
trace(days.date);// It will trace total no. of days(28) in a month
}
showDays(2009, 1);// 1=February

Thanks,
flashDuya.com
this doesn't work...
here's another one I found that's JS but works for AS too.
Code:
function daysInMonth(iMonth, iYear)
{
	return 32 - new Date(iYear, iMonth, 32).getDate();
}

trace(daysInMonth(1, 2009));
peptobismol is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:00 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.