Last active
March 9, 2017 22:08
-
-
Save arozwalak/7369923 to your computer and use it in GitHub Desktop.
Javascript: check apriopriate birth date
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
var checkBirthDate = function(month, year, minAge){ | |
var currentDate = new Date(); | |
var bDate = new Date(parseInt(year)+parseInt(minAge), month); | |
var cDate = new Date(parseInt(currentDate.getFullYear()), parseInt(currentDate.getMonth())+1); | |
if(bDate.getTime() < cDate.getTime()) { | |
return true; } | |
else { | |
return false; } | |
} | |
console.log(checkBirthDate(10, 1995, 18)); |
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
var checkBirthDate = function(month, year, minAge){ | |
var currentDate = new Date(); | |
return ((new Date(parseInt(year)+parseInt(minAge), month)).getTime() < (new Date(parseInt(currentDate.getFullYear()), parseInt(currentDate.getMonth())+1)).getTime()) ? true : false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment