I'm very new to Javascript and can't figure out the following:
1) Ask user to submit their full birthdate (not just the year) and then calculate if their birthday has already happened this year, is today or will be coming up this year.
2) Get a customized message to display depending on these three possible outcomes (eg/ "you already had your birthday this year", "today's your birthday", "your birthday is coming up")
I know it must be simple, but I've googled for a couple days now and can't figure it out.
What I have so far:
function getAge(birth){
var today = new Date();
var nowYear = today.getFullYear();
var nowMonth = today.getMonth();
var nowDay = today.getDate();
var birthYear = birth.getFullYear();
var birthMonth = birth.getMonth();
var birthDay = birth.getDate();
var age = nowYear - birthYear;
var age_month = nowMonth - birthMonth;
var age_day = nowDay - nowDay - birthDay;
if (age_month < nowMonth || age_date < nowday) {
age = parseInt(age) -1;
}
alert("your birthday just happened");
}