Display Running Time

Display Running Time in JavaScript

Details: Display Running Time

This tutorial will give you a basic understanding of how to create a running time using JavaScript and PHP. It is a simple and straight design that serves to give you the required knowledge on how to create the program.

JavaScript: Display Running Time

The PHP code included helps us in displaying our running time. To run this script, you need to create the text by opening your HTML code editor and copy and paste the below code. You can name this script “time.php”.

				
					<span id=tick2>			
<script>
    function show2(){
        if (!document.all&&!document.getElementById)
        return
        thelement=document.getElementById? document.getElementById("tick2"): document.all.tick2
        var Digital=new Date()
        var hours=Digital.getHours()
        var minutes=Digital.getMinutes()
        var seconds=Digital.getSeconds()
        var dn="PM"
        if (hours<12)
        dn="AM"
        if (hours>12)
        hours=hours-12
        if (hours==0)
        hours=12
        if (minutes<=9)
        minutes="0"+minutes
        if (seconds<=9)
        seconds="0"+seconds
        var ctime=hours+":"+minutes+":"+seconds+" "+dn
        thelement.innerHTML=ctime
        setTimeout("show2()",1000)
        }
        window.onload=show2
                //-->
</script>
</span>
 
    <?php
        $date = new DateTime();
        echo $date->format('l -- F j, Y');
    ?>
				
			

Create a display page: Display Running Time

For the final page, we need to display our running time on a page for view. To create this page, copy and paste the code below after the tag in your HTML code editor and you can save page as “index.php”.

				
					<!DOCTYPE HTML>
<html>
<head>
<title>Simple Running Time using PHP</title>
</head>
<body>
    <?php include ('time.php'); ?>
</body>
</html>
				
			

Result: Display Running Time

Display Running Time, javascript, free source code, runtime, free download, source code

We have successfully illustrated the tutorial with the above codes.

Don’t forget to share this post!

Leave a Comment

Your email address will not be published. Required fields are marked *

Related Article