Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > HTML > HTML Code Clinic
|
HTML Code Clinic Do you have some HTML code you'd like to share and get suggestions from others for tweaking or improving it? This discussion is the place.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the HTML Code Clinic section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 14th, 2003, 06:08 AM
Authorized User
 
Join Date: Aug 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to spraveens
Default Displying Date/time inside a text field

Hi all

        I would like to know how to display the current date or time inside a text field of a form in a html page.

Thank You .

Praveen ;)

 
Old November 14th, 2003, 12:06 PM
Registered User
 
Join Date: Nov 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try this:
<html>
<head>
<script>
function dateString(){
    var tday=new Date();
    var tdayy=tday.getYear();
    if (tdayy < 1000)
        tdayy+=1900;
    var tdaym=tday.getMonth();
    var tdayd=tday.getDate();
    var tdayh=tday.getHours();
    var tdaymin=tday.getMinutes();
    if (tdaymin<10) tdaymin='0'+tdaymin.toString();
    var tdaysec=tday.getSeconds();
    if (tdaysec<10) tdaysec='0'+tdaysec.toString();
    DateTimeStr=tdaym+'/'+tdayd+'/'+tdayy+' '+tdayh+':'+tdaymin+':'+tdaysec
    return DateTimeStr;
}
</script>
</head>
<body>
<input type='text' name='DispDT'>
<script>
    DispDT.value=dateString();
</script>
</body>
</html>





Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing Text Data to Date/Time jjc9809 Access 4 January 22nd, 2006 07:41 PM
Null Value for Date/Time Field ksegars4 Crystal Reports 2 November 17th, 2004 11:58 AM
Convert Text to Date/Time in Access mmcdonal Access VBA 7 June 15th, 2004 12:19 PM
SQL2000 Date/Time field update Lucian Ion Dreamweaver (all versions) 9 January 2nd, 2004 09:14 PM
Format Date to time field KennethMungwira VB.NET 3 November 17th, 2003 11:48 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.