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

#clock {
#datetime {
height: 100px;
width: 800px;
margin: auto;
position: absolute;
top: 0; left: 0; bottom: 0; right: 0;
padding-top: 70px;
margin-top: 200px;
font-family: courier, monospace;
text-align: center;
color: white;
Expand Down
11 changes: 9 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,15 @@
</head>

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

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

// var addZero = function(digit) {
// if (digit < 10) {
// digit = "0" + digit;
// }
// return digit;
// };

var showTime = function() {
var today = new Date();
var options = { weekday: 'long', year: 'numeric', month: '2-digit', day: '2-digit', hour: "2-digit", minute: "2-digit", second: "numeric" };
var dateTime = today.toLocaleString('en-US', options);

// days = addZero(today.getDate()),
// months = addZero(today.getMonth()),
// years = today.getFullYear(),
// hours = today.getHours(),
// minutes = addZero(today.getMinutes()),
// seconds = addZero(today.getSeconds()),
// ampm = hours > 11 ? ' PM' : ' AM',
// americanHours;
//
// if (hours === 0) {
// americanHours = 12;
// } else if (hours < 13) {
// americanHours = hours;
// } else {
// americanHours = addZero(hours % 12);
// }
//
// $("#date").html(months + "/" + days + "/" + years);
// $("#clock").html(americanHours + ":" + minutes + ":" + seconds + ampm);

$("#clock").html(dateTime);

};

setInterval(showTime, 1000);
});