I'm trying to create a script that if today's date is before January 16, the current year will print, but if today's date is greater than or equal to January 16, the following year will print.
I am pretty new to coding JavaScript so perhaps I am just missing something stupid. Can anyone help by looking over this code and tell me what I did wrong?
<script type="text/javascript">
var today = new Date();
var mm = today.getMonth()+1; //January is 0!
var dd = today.getday();
if (mm < 10) {
mm = '0'+mm
}
var today = new Date("mm/dd")
var other = new Date("01/16")
if (today < other){
var printDate = theDate.getFullYear();
}
else if (today >= other){
var printDate = theDate.getFullYear()+1;
}
</script>
Then in the HTML:
<strong>16 January</strong> <script>document.write(printDate);</script>
Output right now is "undefined." Any ideas would be greatly appreciated!