Reputation: 11
I've tried various answers to other questions and looked through my notes, but I'm still struggling to make this work. I want the current date to appear on my page in the format dd/mm/yyyy. So for example if I was on the page today it would read 02/11/2014 and tomorrow it would read 03/11/2014 etc.
This is the current code I've been fiddling around with, but its not working for me. I'm clearly overlooking something but I can't figure out what. Would be great if someone could help me out, I understand this is probably something very simple but my brain has gone to mush haha!
<div id="date">
<script type="text/javascript">
var currentTime;
currentTime = new Date ();
var thisDate = currentTime.getDate();
var thisMonth = currentTime.getMonth();
var thisYear = currentTime.getFullYear();
document.write(date + month + year);
</script>
Upvotes: 1
Views: 79
Reputation: 3783
date, month and year arent declared in your code, you should use the right variables.
var thisDate = currentTime.getDate();
var thisMonth = currentTime.getMonth();
var thisYear = currentTime.getFullYear();
document.write(thisDate + '/' + thisMonth + '/' + thisYear);
Upvotes: 1