Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

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.

<body>

....

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

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

</form>
<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;

</script>
.....

</body>



This post first appeared on Php Source Codes, please read the originial post: here

Share the post

Displaying current date in textbox at page on load

×

Subscribe to Php Source Codes

Get updates delivered right to your inbox!

Thank you for your subscription

×