aatwo
02-07-2007, 11:13 PM
<script language="Javascript">
//Function that returns a timestamp in the form 'fullYear-month-day hour:minute:second'
//Eg: The 24'th of December 1999 at 12 seconds past 8:42pm would return '1999-12-24 20:42:12'
function currentDate(){
var d = new Date(), day, month, year,date="", hour, minute, second;
day=d.getDate();
month=d.getMonth() + 1;
year=d.getFullYear();
hour=d.getHours();
minute=d.getMinutes();
second=d.getSeconds();
date=date+year+"-"+month+"-"+day+" "+hour+":"+minute+":"+second;
document.getElementById("currentDate").value=date;
document.getElementById("modifyDate").value=date;
}
</script>
I have the above javascript in the header of my page and in the body I call the function when a button is clicked.
<input type="button" value="testButton" onclick="currentDate();">
Why the hell does the error console say that 'currentDate' is not a function ?
//Function that returns a timestamp in the form 'fullYear-month-day hour:minute:second'
//Eg: The 24'th of December 1999 at 12 seconds past 8:42pm would return '1999-12-24 20:42:12'
function currentDate(){
var d = new Date(), day, month, year,date="", hour, minute, second;
day=d.getDate();
month=d.getMonth() + 1;
year=d.getFullYear();
hour=d.getHours();
minute=d.getMinutes();
second=d.getSeconds();
date=date+year+"-"+month+"-"+day+" "+hour+":"+minute+":"+second;
document.getElementById("currentDate").value=date;
document.getElementById("modifyDate").value=date;
}
</script>
I have the above javascript in the header of my page and in the body I call the function when a button is clicked.
<input type="button" value="testButton" onclick="currentDate();">
Why the hell does the error console say that 'currentDate' is not a function ?