Click to See Complete Forum and Search --> : Display the current date
cezza30
02-26-2003, 04:36 PM
I've got a form on which is a text box that I would like to be filled with the current date, in the format YYYY-MM-DD.
Is this possible??? If so . . . how?
Thank you in advance
Charles
02-26-2003, 04:45 PM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Content-Script-Type" content="text/javascript">
<title>Date Example</title>
<script type="text/javascript">
<!--
Date.prototype.toString = function () {return [this.getFullYear(), this.getMonth() < 9 ? '0' + Number (this.getMonth() + 1) : this.getMonth() + 1, this.getDate() < 10 ? '0' + this.getDate() : this.getDate()].join('-')};
onload = function () {document.foo.date.value = new Date(2003,8,25)};
// -->
</script>
<form action="someScript" name="foo">
<p><label for="date">Date</label><br>
<input type="text" id="date"></p>
<p><input type="submit"></p>
</form>