Monday, 8 September 2014

Count no. of dates in a month java scripts

<html>
<body>



<p id="demo"></p>

<script>
 function getDaysInMonth(m, y) {
     return /8|3|5|10/.test(--m)?30:m==1?(!(y%4)&&y%100)||!(y%400)?29:28:31;
}
document.getElementById("demo").innerHTML = getDaysInMonth(8, 2014);
</script>


</body>
</html>

No comments:

Post a Comment