Nice for a first time. Are you posting to show us or because it doesn't work?
To make it work the Date() function has to return something. Give this a try:
Code:
<!DOCTYPE html>
<html lang="en">
<head>
<script type="text/javascript">
function returnDate(){
var now = new Date(); // this returns the amount of milliseconds since 1/1/1970, which is how we'll get the current date
var month = now.getMonth()+1; // just to get the month, all we do is use the date object we've initialized, and call the getMonth function. But, because the months are indexed to 0 (meaning months are numbered 0-11), we have to add 1
var day = now.getDate(); // get the day
var year = now.getYear(); // get the year
return month + "/" + day + "/" + year;
}
function displayDate() {
document.getElementById("demo").innerHTML = returnDate();
}
</script>
</head>
<body>
<h1>Time and Date</h1>
<time id="demo">mm/dd/yyyy</time><input type="button" onclick="displayDate()" value="Display date">
</body>
</html>
Bookmarks