I have some code which generates a dynamic date string, I want to put in into a web link so I can call the link to generate a new image each day.
I have written this code:
<script>
var d = new Date();
var year = d.getFullYear();
var month = d.getMonth() + 1;
var day = d.getDate();
document.getElementById("link").href = "http://earth.nullschool.net/#" + year + "/" + month + "/" + day + "/1200Z/wind/isobaric/500hPa/";
</script>
<a href="http://earth.nullschool.net/#2012/01/24/1200Z/wind/isobaric/500hPa/" id="link">500 mb Earth Wind Map</a>
However when I click this link it goes to the old date (2012), not the current date that the javascript creates. How do I create the link with today's date inside it?