DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 3 of 3

Thread: JavaScript Help

  1. #1
    Join Date
    Oct 2005
    Posts
    95

    JavaScript Help

    Hi

    I have a quick java script question . I am developing a java script application where I have to create a date format in days:hours:minutes:seconds . If the seconds are more than 60 then the system will show minutes:seconds .If the minute is more than 60 the system will show hours:minutes:seconds . If the hour is more than 24 then the system will show days:hours:minutes:seconds . How do I do that . Please so me some code sample in java script

    Thanks

  2. #2
    Join Date
    Apr 2006
    Posts
    28
    Here is JavaScript , it may help you
    good luck


    <!---Runing Clock------ document.Clock.display.value=clock; ---->
    <html>
    <body>
    <script type="text/javascript">
    var timer=null
    function stop()
    { clearTimeout(timer)

    }
    function start()
    {
    var time=new Date()
    var hours=time.getHours()
    var minutes=time.getMinutes()
    var seconds=time.getSeconds()
    var clock=time+hours
    clock +=((minutes<10)?":0":":")+minutes
    clock +=((seconds<10)?":0":":")+seconds
    document.forms[0].display.value=clock;
    <!---Runing Clock------ document.Clock.display.value=clock; ---->
    <!---Display is a textbox and receive value , 1000 = 1 second and will call function again so we have clock; ---->
    <!---Will stop when we call another webpage ---->
    timer=setTimeout("start()",1000);
    }

    </script>
    </head>
    <body onload="start()" onunload="stop()">
    <form>
    <input type="text" name="display">
    </form>
    </body>
    </html>

  3. #3
    Join Date
    Oct 2005
    Posts
    95

    Java Script Time format help

    Hi

    Thanks for the reply . The Java script you provided is working but it does not give the result that I need . I need to create a time format in java script ( days:hours:minutes:seconds) . When there are only 59 seconds or less the system will only show the seconds . When the seconds are more that 59 for example 64 seconds then the system will show 5:04 ( 5 minutes:04 seconds ) . When the minutes are more than 59 for example 64 minutes then the system will show 04:05:04 ( hours:minutes:seconds ) and if the hours are more than 24 then the system will show the time in days:hours:minutes:seconds format . Please help

    Thanks

Similar Threads

  1. Replies: 5
    Last Post: 05-06-2006, 10:22 PM
  2. problems with javascript
    By Michael in forum ASP.NET
    Replies: 10
    Last Post: 11-08-2005, 12:19 PM
  3. Help with Javascript in forms
    By Keith Sarver in forum Web
    Replies: 0
    Last Post: 12-14-2002, 02:18 PM
  4. Agents and JavaScript how??
    By Hakan Eren in forum Enterprise
    Replies: 0
    Last Post: 08-31-2001, 05:16 AM
  5. Sample Sites.
    By Murray Foxcroft in forum Web
    Replies: 5
    Last Post: 11-02-2000, 02:42 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links