Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding the current date to a hidden field 1

Status
Not open for further replies.

megasuperman

Programmer
Aug 20, 2001
21
US
I need to add the Current date in Short Date format to a hidden field

therefore Date() New Date() and such will not work

I get thiis
Sun Aug 26 15:37:04 2001

08-26-2001

0r 8-26-001

or 8/26/01

or whatever

THANX
 
culd u plz post ur solution for other people who wuld be in search on this subject?

thanks Victor
 
<script>
function myDate(){
var tday=new Date();

var hr = tday.getHours();
var dy = (tday.getDate() + 1);
var yr = tday.getYear();
var mn = (tday.getMonth() + 1);
document.form1.date1.value = (yr.toString() + &quot;-&quot; + mn+ &quot;-&quot; + dy)
}

</script>
</head>

<body onLoad=myDate()>
<form name=&quot;form1&quot;>
<input type=&quot;text&quot; name=&quot;date1&quot;>
</form>
</body>

Change the bold area to format the date to &quot;look&quot; the way you want. You can also use document.write rather than a form DeZiner
gear.gif width=45 align=left
When the gears stop turning,
we all stop learning.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top