Skip to main content

How to create a dynamic digital clock for your website using javascript

Dynamic Digital Clock

How to create a dynamic digital clock for your website using javascript

Time :
Day :


Click to see the clock

Just copy and past on your website
Source : 

<!DOCTYPE html>
<html>
<head>
<script>
function startTime() {
    var today = new Date();
    var h = today.getHours();
    var m = today.getMinutes();
    var s = today.getSeconds();
    m = checkTime(m);
    s = checkTime(s);
    document.getElementById('clock').innerHTML =
    h + ":" + m + ":" + s;
    var t = setTimeout(startTime, 500);



var today = new Date();
    var day = today.getDate();
    var month = today.getMonth();
    var year = today.getFullYear();
 
    document.getElementById('day').innerHTML =
    day + "/" + month + "/" + year;
    var d = setTimeout(startTime, 500);
}
function checkTime(i) {
    if (i < 10) {i = "0" + i};  // add zero in front of numbers < 10
    return i;
}


function checkTime(i) {
    if (i < 10) {i = "0" + i};  // add zero in front of numbers < 10
    return i;
}
</script>
<style>
.deco
{
text-align:center;
font-family:arial;
font-size:50px;
}
</style>
</head>
<body onload="startTime()">
<div class="deco">Time : <strong id="clock"></strong></div>
<div class="deco">Day : <strong id="day"></strong></div>
</body>
</html>

Output :

Comments

Popular posts from this blog

How to create a calculator using HTML, CSS & JavaScript

Create a Calculator Using HTML ,CSS & JavaScript Download HTML file Source : <!doctype html> <html> <head> <meta charset="utf-8"> <title>Dynamic Calculator</title> <style> body { background:#ecf0f1; font-family:arial; } #calBody { padding:10px; background:#3498db; width:300px; height:310px; margin:auto; top:0px; right:0px; left:0px; bottom:0px; position:absolute; -webkit-box-shadow: 0px 1px 1px 1px rgba(0,0,0,0.15); -moz-box-shadow: 0px 1px 1px 1px rgba(0,0,0,0.15); box-shadow: 0px 1px 1px 1px rgba(0,0,0,0.15); } #calBody h1 { color:#ecf0f1; font-weight:normal; text-align:center; } #calBody input, #answer { padding:10px; width:270px; border:none; margin:auto; display:block; margin-bottom:10px; font-size:24px; color:#34495e; background:#ecf0f1; } #buttons { width:230px; margin:auto; ...

Data units and bits and bytes

Data units and bits and bytes A bit is smallest unit in data, 1 bit = one binary digit 0 or 1 For Processing or virtual 1 bit = One binary digit (0 or 1) 1 nibble = 4 bit 1 byte = 8 bit 1024  bytes = 1 KB (Kilobyte) 1024 KB = 1 MB (Megabyte) 1024 MB = 1 GB (Gigabyte) 1024 GB = 1 TB (Terabyte) 1024 TB = 1 PB (Petabyte) 1024 PB = 1 EB (Exabyte) 1024 EB = 1 ZB (Zettabyte) 1024 ZB = 1 YB (Yottabyte) 1024 YB = 1 BB (Brontobyte) 1024 BB = 1 GB (Geopbyte) For Storage 1 bit = One binary digit (0 or 1) 1 nibble = 4 bit 1 byte = 8 bit 1000 bytes = 1 KB (Kilobyte) 1000 KB = 1 MB (Megabyte) 1000 MB = 1 GB (Gigabyte) ...

Create dynamic table using bootstrap (filter & find records)

Data Table With Bootstrap Download HTML file Into : In this table, you can short, filtering, find the record and many features you have been used but its very easy to use and configure. so don't get late lets introducing data table CSS:  Data table Stylesheet JS:   Data table js download this for your next project. or you can copy and paste bellow con on your project it's definitely working. Source : <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Data Table</title> <script src="https://code.jquery.com/jquery-1.12.4.js"></script> <script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script> <script src="https://cdn.datatables.net/1.10.16/js/dataTables.bootstrap4.min.js"></script> <script> $(document).ready(function(){       $('#myTable').DataTable(); }); </script> <link...