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
@@ -1,8 +1,8 @@
body {
background-color: #80d4ea;
background-color: #74D9DE;
}

#clock {
.clock {
height: 100px;
width: 800px;
margin: auto;
Expand Down
9 changes: 8 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,15 @@
</head>

<body>
<div id='clock'></div>
<div class="clock" id='PST'></div>
<!-- <div class="clock" id='EST'></div>
<div class="clock" id='CEST'></div>
<div class="clock" id='JST'></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>
34 changes: 33 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1 +1,33 @@
// Your code here
$(document).ready(function() {

getTime();
// getTime('#EST');
// getTime('#CEST');
// getTime('#JST');

// Use the setInterval method to utilize the function you've created to update each second.
window.setInterval(getTime, 1000);

function getTime() {
// Use the Date Library in Javascript to retrieve the current date and time information.
var timeNow = new Date();
// I tried using arguments to get this to work but then the callback in the setInterval stopped working mysteriously :C
// if ( id == '#PST' ) {
// var timeNow = new Date();
// } else if ( id == '#EST' ) {
// var timeNow = new Date() + 180;
// } else if ( id == '#CEST' ) {
// var timeNow = new Date() + 480;
// } else if ( id == '#PST' ) {
// var timeNow = new Date() + 960;
// }

// Use the different methods that are provided to you for retrieving the individual hour, minute and second information.
var hours = ('0' + timeNow.getHours()).slice(-2);
var minutes = ('0' + timeNow.getMinutes()).slice(-2);
var seconds = ('0' + timeNow.getSeconds()).slice(-2);
var timeDisplay = $("<p>" + hours + " : " + minutes + " : " + seconds + "</p>");

$('div').html(timeDisplay);
}
});