Created
July 25, 2015 11:26
-
-
Save ihorkatkov/5830abb8e21960dc35a1 to your computer and use it in GitHub Desktop.
getLastDayOfMonth(year, month) - возвращает последний день месяца
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getLastDayOfMonth(year, month) { | |
var currentMounth = new Date(year, month); | |
var nextMounth = new Date(year, month + 1); | |
var result = (nextMounth - currentMounth)/86400000; | |
return result; | |
} | |
/* | |
Лучшее решение | |
function getLastDayOfMonth(year, month) { | |
var date = new Date(year, month + 1, 0); | |
return date.getDate(); | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment