0% found this document useful (0 votes)
12 views3 pages

Time Difrence

The document contains multiple HTML examples demonstrating JavaScript functionalities. It includes a time difference calculator, a timeout function that redirects after 5 seconds, and two interval functions that either increment a counter or display the current time every second. Each example is structured with input fields and buttons for user interaction.

Uploaded by

leenagadadare10
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views3 pages

Time Difrence

The document contains multiple HTML examples demonstrating JavaScript functionalities. It includes a time difference calculator, a timeout function that redirects after 5 seconds, and two interval functions that either increment a counter or display the current time every second. Each example is structured with input fields and buttons for user interaction.

Uploaded by

leenagadadare10
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

Start time And End Time Diffrence

---------------------------------------------------------------------

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<script>
function calculate() {
var st = document.getElementById("a1").value;
var et = document.getElementById("a2").value;

var sdt = new Date("01 19 2025 " + st);


var edt = new Date("01 19 2025 " + et);

var time = (((edt - sdt) / 1000) / 60);

var h = Math.floor(time / 60);


var m = time % 60;

document.getElementById("num1").innerHTML = h + " Hour" + " : " + m + "


Minute";

}
</script>
</head>
<body>
Start Time :=<input type="time" id="a1" /><br /><br />
End Time :=<input type="time" id="a2" /><br /><br />

<input type="button" value="Submit" onclick="calculate()" />

<h1 id="num1"></h1>
</body>
</html>

===================================================================================
====================

Set time out function

---------------------------------------

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<script>
function Display() {
document.getElementById("num1").innerHTML = "Welcome to Ciit Webpage";

setTimeout(function () {
window.location.href = "https://ciitinstitute.com/";
},5000)
}
</script>
</head>
<body onload="Display()">

<h1 id="num1"></h1>

</body>
</html>

===================================================================================
===========================

Set Interval function

----------------------------------------------------------
count increase Automatic
------------------------------------

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<script>
var i = 1;
function Display() {
document.getElementById("num1").innerHTML = i;

setInterval(function () {
i++;
document.getElementById("num1").innerHTML = i;
},1000)
}
</script>
</head>
<body onload="Display()">
<h1 id="num1"></h1>
</body>
</html>

===================================================================================
==================

Set Interval function ( time continue run with sec)

------------------------------------------------------------
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<script>
function Display() {
var dt = new Date();
document.getElementById("num1").innerHTML = dt.toLocaleTimeString();

setInterval(function () {
var dt = new Date();
document.getElementById("num1").innerHTML =
dt.toLocaleTimeString();

},1000)
}
</script>
</head>
<body onload="Display()">
<h1 id="num1"></h1>
</body>
</html>

===================================================================================
===============================

You might also like