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
9 changes: 6 additions & 3 deletions index.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ body {
background-color: #80d4ea;
}

#clock {
height: 100px;
width: 800px;
#clock, #date {
margin: auto;
position: absolute;
top: 0; left: 0; bottom: 0; right: 0;
Expand All @@ -14,3 +12,8 @@ body {
color: white;
font-size: 100px;
}

#clock {
height: 100px;
width: 800px;
}
11 changes: 9 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
<!DOCTYPE html>

<html>

<head>
<title>Clock Tower</title>
<meta charset="utf-8">
<link href="index.css" media="screen" rel="stylesheet" type="text/css"/>
</head>

<body>
<div id='date'></div>
<div id='clock'></div>
<script
src="https://code.jquery.com/jquery-3.2.1.min.js"
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
crossorigin="anonymous"></script>
<script src="index.js"></script>
</body>
</html>

<script src="index.js"></script>
</html>
42 changes: 42 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1 +1,43 @@
// Your code here

$(document).ready(function() {

setInterval(function(){
var date = new Date();
var seconds = date.getSeconds();
var minutes = date.getMinutes();
var hours = date.getHours();
var month = date.getUTCMonth() + 1;
var day = date.getDate();
var weekday = date.getDay();
var year = date.getFullYear();
var amPm = 'AM';



var twelveHour = function(hour){
if(hour > 12 ){
hour = hour - 12;
amPM = 'PM';
}
return hour;
};

var twoNums = function(component) {
if (component < 10) {
display = "0" + component;
} else {
display = component;
}
return display;
};


var time = twelveHour(hours) + ":" + twoNums(minutes) + ":" + twoNums(seconds) + " " + amPM;
var currentDate = month + "/" + day + "/" + year;
$('#date').text(currentDate);
$('#clock').text(time);
}, 1000);


});