|
||||||||||||||||||||||||||
JS Tutorial
part i - JS language
Part ii - JS objects
Part ii - Client-Side JS
JS Articles |
JavaScript Frequently Ask Question How to determine number of days with JavaScript? by Puthyrak Kang September 17, 2009
JavaScript does not have a built-in function to determine a number of days in a given month
of a given year. However, JavaScript
<script type="text/javascript">
function daysInMonth(month, year){
var nbrOfDays = 32 - new Date(month, year, 32).getDate();
return nbrOfDays;
}
//Calculate the number of day of January, 2010
alert("Number of day in January, 2010 is: "+ daysInMonth(1,2010));
//Calculate the number of day of the current month
var cDay = new Date();
alert("Number of days in the current month is: "
+daysInMonth(cDay.getMonth(),cDay.getFullYear()));
</script>
|
References(1) Aland Shalloway & James R. Trott, Design Patterns Explained, Second Edition.(2) Allen Holub, Holub on Patterns, Learning Design Patterns by Looking at Code (3) Eric Evans, Domain-Driven Design, Tackling complexity in the heart of software. Advertisement |
||||||||||||||||||||||||
|
||||||||||||||||||||||||||