I'm not an expert in JavaScript, but I've been tasked with migrating a very large website that was coded into PHP into a new CMS that does not allow server-side languages. I am therefore spending my days converting many PHP date-calcs to JavaScript.
Something very simple in PHP:
<?php
if (date('md') < 816) {$award_year = date('Y');}
if (date('md') > 815) {$award_year = date('Y') + 1;}
/*echo "year ".$award_year;*/
?>
This allows the year an application is due to automatically change to next year after August 15.
I've been trying to recreate this effect with Javascript and here is what I have come up with:
var today = new Date();
var mm = today.getMonth()+1; //January is 0!
var dd = today.getday();
if (mm < 10) {
mm = '0'+mm
}
currDate = mmdd;
var currDate = new Date();
var appDate = new Date("0816");
if (currDate < appDate){
var printDate = theDate.getFullYear();
}
else if (currDate >= appDate){
var printDate = theDate.getFullYear()+1;
}
I know that I am missing something, because the var currDate cannot just = mmdd and then be compared to another date. Can someone help me with the next step here ? I'm trying to actually learn JavaScript as I go rather than just blindly fix issues.