Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@
<meta charset="utf-8">
<link href="index.css" media="screen" rel="stylesheet" type="text/css"/>
</head>

<body>
<div id='clock'></div>
<div id='clock'>
</div>
</body>
</html>

<script src="https://code.jquery.com/jquery-3.2.1.min.js"
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
crossorigin="anonymous"></script>

<script src="index.js"></script>
24 changes: 24 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1 +1,25 @@
// Your code here
$(document).ready(function() {

//sets the inteval to 1000 milliseconds (1 second).
//this allows the time fucntion to be called every second.
var secondsInterval = setInterval(function(){ time() }, 1000);


function time() {
//date class gets current date
var currentDate = new Date();
//toLocaleTimeString takes the current date and converts it
var localTime = currentDate.toLocaleTimeString();
//jquery calls the div where the id is 'clock' and inputs the localTime. The tim fucntion is being called every second and flashes on screen.
$('#clock').html(localTime);
}

});




// var listItem = $('<li>' + i + '</li>');

// new Date(year, month[, date[, hours[, minutes[, seconds[, milliseconds]]]]]);