I want to add this code in a custom HTML widget of wordpress website but the problem is that I am unable to create and use date-wise image link. By seeing the code below, please tell me what is wrong here and how to correct it:
<html>
<head>
<script type="text/javascript">
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();
if(dd<10){
dd='0'+dd;
}
if(mm<10){
mm='0'+mm;
}
var today = yyyy+'/'+mm+'/'+'dd';
var link = "http://e.piyarawatan.com/paper/" + today + "p-1.jpg";
</script>
</head>
<body>
<img src='<script type=javascript>link</script>'>aaa</img>
</body>
</html>
The output should be an image but it is not. Here the the output:
aaa
After compiling, the image goes to this link : http://news.piyarawatan.com/%3Cscript%20type=javascript%3Elink%3C/script%3E which is an invalid link