IT Community - Software Programming, Web Development and Technical Support

Number of days in a month (or last day of a month)

This is a discussion on Number of days in a month (or last day of a month) within the HTML, CSS and Javascript Coding Techniques forums, part of the Web Development category; Hi all... Can anyone tell me how can i find the number of days in a month (or last day ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > HTML, CSS and Javascript Coding Techniques

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 03-20-2008, 10:06 PM
itbarota itbarota is offline
D-Web Architect
 
Join Date: Jun 2007
Posts: 547
itbarota is on a distinguished road
Default Number of days in a month (or last day of a month)

Hi all...


Can anyone tell me how can i find the number of days in a month (or last day of a month).


Thanks in advance...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 03-20-2008, 10:07 PM
Pvinothkumar Pvinothkumar is offline
D-Web Analyst
 
Join Date: Sep 2007
Posts: 237
Pvinothkumar is on a distinguished road
Default Re: Number of days in a month (or last day of a month)

Hi all...


<script language="JavaScript">
var daysofmonth = new makeArray( 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
var daysofmonthLY = new makeArray( 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

function LeapYear(year) {
if ((year/4) != Math.floor(year/4)) return false;
if ((year/100) != Math.floor(year/100)) return true;
if ((year/400) != Math.floor(year/400)) return false;
return true;
}

function y2k(number) { return (number < 1000) ? number + 1900 : number; }

var today = new Date();
var year = y2k(today.getYear());

if (LeapYear(year) {
daysofmonth = daysofmonthLY;
}

alert('February ' + year + ' has ' + daysofmonth[1] + ' days');
</script>



Thanks...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-28-2008, 08:47 PM
GDevakii GDevakii is offline
D-Web Sr.Programmer
 
Join Date: Aug 2007
Posts: 138
GDevakii is on a distinguished road
Smile Re: Number of days in a month (or last day of a month)

function daysInMonth(month,year) {
var m = [31,28,31,30,31,30,31,31,30,31,30,31];
if (month != 2) return m[month - 1];
if (year%4 != 0) return m[1];
if (year%100 == 0 && year%400 != 0) return m[1];
return m[1] + 1;
}
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find the last day of the month for any given month. itbarota HTML, CSS and Javascript Coding Techniques 1 03-17-2008 08:56 PM
Calculate how many hours per each month itbarota HTML, CSS and Javascript Coding Techniques 1 02-25-2008 09:23 PM
calculate the number of days in the current month itbarota HTML, CSS and Javascript Coding Techniques 1 02-08-2008 06:30 AM
Get Last Day of the Month Function srikumar_l Database Support 0 12-21-2007 08:40 PM
Get First Day of the Month Function srikumar_l Database Support 0 12-21-2007 08:37 PM


All times are GMT -7. The time now is 12:35 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0