Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jordan Freundlich #42

Closed
wants to merge 2 commits into from
Closed
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
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"liveServer.settings.port": 5503
}
40 changes: 40 additions & 0 deletions clock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
const hourHand = document.getElementById("hour");
const minuteHand = document.getElementById("minute");
const secondHand = document.getElementById("second");

//function runs clock
function clockRun(){
//creates date. Accesses current day and time
const date = new Date();
console.log(date)

//creates hour variable. Prints to military time so out of 24
let hours = date.getHours()
//console.log(hours)

//creates minute variable. Prints 0-60.
let minutes = date.getMinutes()
//console.log(minutes)

// creates seconds variable. Prints 0-60
let seconds = date.getSeconds()

let secondRotation = (seconds/60)
let minuteRotation = (minutes/60)
let hourRotation = (((minuteRotation) + hours)/12)

//console.log(seconds);

//gets the seconds to run!!
secondHand.style.transform = "rotate(" + (secondRotation * 360) + "deg)"

//get the minutes to run!!
minuteHand.style.transform = "rotate(" + (minuteRotation * 360) + "deg)"

//gert the hours to run!
hourHand.style.transform = "rotate(" + (hourRotation * 360) + "deg)"

}

setInterval(clockRun,1000)

7 changes: 7 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
#clock {
position: relative;
}

#clock img {
position: absolute;

}


#hour {
position: absolute;
}

#minute {
position: absolute;
}

#second {
position: absolute;
}