Displaying current date in textbox at page on load

Displaying current date in textbox at page on load is very with a single function, I checked this function by putting the script in between head tags but i didn't work, Then again i put in the body section then it working perfectly.
This function reads current system time of our PC. But i am not fully satisfy with this code i want to be with global internet date. Mean while the code is as follows , hope it will helpful you guys.



<form action="" method="post">

<input id="currentdate" name="currentdate" size="20" />

<script type="text/javascript">

var currenttime = new Date();
var month = currenttime.getMonth() + 1;
var day = currenttime.getDate();
var year = currenttime.getFullYear();

document.forms[0].currentdate.value = month + "-" + day + "-" + year;




web design uk said...

Thanks a lot for sharing this nice post!You’ve done really excellent job!

Sinelogix said...

hey guys well done and thanks for share this information
Web Designer in Bangalore

Kepran Infosoft said...

Good Article
Ecommerce Web Development Services