How to set 'rotate()' value to match current time?How to tell if a DOM element is visible in the current viewport?How to measure time taken by a function to executeHow do you access the matched groups in a JavaScript regular expression?Set a default parameter value for a JavaScript functionHow can I get query string values in JavaScript?How to get the value from the GET parameters?How can I add a key/value pair to a JavaScript object?How do I set/unset a cookie with jQuery?How do I get the current date in JavaScript?how to format time on xAxis use d3.js
What size of powerbank will I need to power a phone and DSLR for 2 weeks?
How do I set an alias to a terminal line?
Is "Busen" just the area between the breasts?
What can I do with a research project that is my university’s intellectual property?
Why does Linux list NVMe drives as /dev/nvme0 instead of /dev/sda?
Has there been any indication at all that further negotiation between the UK and EU is possible?
Why don't countries like Japan just print more money?
How does a blind passenger not die, if driver becomes unconscious
What is "industrial ethernet"?
Why do textbooks often include the solutions to odd or even numbered problems but not both?
JSON selector class in Python
Trainee keeps missing deadlines for independent learning
How to get cool night-vision without lame drawbacks?
How does the spell Remove Curse interact with a Sword of Vengeance?
Did the CIA blow up a Siberian pipeline in 1982?
How can I politely work my way around not liking coffee or beer when it comes to professional networking?
Why does the Saturn V have standalone inter-stage rings?
Greeting with "Ho"
What reason would an alien civilization have for building a Dyson Sphere (or Swarm) if cheap Nuclear fusion is available?
How does DC work with natural 20?
Why do some professors with PhDs leave their professorships to teach high school?
Can there be an UN resolution to remove a country from the UNSC?
Should developer taking test phones home or put in office?
What does the hyphen "-" mean in "tar xzf -"?
How to set 'rotate()' value to match current time?
How to tell if a DOM element is visible in the current viewport?How to measure time taken by a function to executeHow do you access the matched groups in a JavaScript regular expression?Set a default parameter value for a JavaScript functionHow can I get query string values in JavaScript?How to get the value from the GET parameters?How can I add a key/value pair to a JavaScript object?How do I set/unset a cookie with jQuery?How do I get the current date in JavaScript?how to format time on xAxis use d3.js
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I'm trying to make a clock in javascript. I can't figure out how to set the value of rotate() equal to the degree of the current time.
I've tried some methods.
I've looked at these tutorials:
- https://cssanimation.rocks/clocks/
- https://medium.com/@abhi95.saxena/make-an-analog-clock-using-javascript-7c07580ea91b
This is what I have right now and I believe it should work like this.
HTML:
<div class="analogClock">
<div class="hours-container" id="pointer">
<div class="hours"></div>
</div>
<div class="minutes-container" id="pointer">
<div class="minutes"></div>
</div>
<div class="second-container" id="pointer">
<div class="seconds"></div>
</div>
</div>
CSS:
.analogClock
border-radius: 50%;
background-color: #11052B;
height: 20em;
width: 20em;
position: relative;
.second-container, .minutes-container, .hours-container
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
.hours
background-color: #E83063;
height: 20%;
left: 50%;
position: absolute;
top: 50%;
transform-origin: 50% 100%;
width: 2.5%;
border-radius: 50px;
.minutes
background-color: #6CE4FF;
height: 30%;
left: 50%;
position: absolute;
top: 50%;
transform-origin: 50% 100%;
width: 2%;
border-radius: 50px;
.seconds
background-color: #59FF8C;
height: 40%;
left: 50%;
position: absolute;
top: 50%;
transform-origin: 50% 100%;
width: 1%;
z-index: 8;
border-radius: 50px;
.hours-container
animation: rotate 43200s infinite steps(12);
.minutes-container
animation: rotate 3600s infinite steps(60);
.second-container
animation: rotate 60s infinite steps(60);
@keyframes rotate
100% transform: rotateZ(360deg);
JS:
//Analog clock
const hourPointer = document.querySelector('.hours-container');
const minutePointer = document.querySelector('.minutes-container');
const secondPointer = document.querySelector('.second-container');
function analogClock()
var date = new Date();
var seconds = date.getSeconds();
var minutes = date.getMinutes();
var hours = date.getHours();
let hrPosition = hours*360/12 + ((minutes * 360/60)/12) ;
let minPosition = (minutes * 360/60) + (seconds* 360/60)/60;
let secPosition = seconds * 360/60;
hourPointer.getElementsByClassName.transform = 'rotate(' + hrPosition + 'deg)';
minutePointer.getElementsByClassName.transform = 'rotate(' + minPosition + 'deg)';
secondPointer.getElementsByClassName.transform = 'rotate(' + secPosition + 'deg)';
var interval = setInterval(analogClock, 500)
I want the hands to point at the current time, but they start from the bottom no matter what time it is.
Thanks for your time!
javascript
add a comment |
I'm trying to make a clock in javascript. I can't figure out how to set the value of rotate() equal to the degree of the current time.
I've tried some methods.
I've looked at these tutorials:
- https://cssanimation.rocks/clocks/
- https://medium.com/@abhi95.saxena/make-an-analog-clock-using-javascript-7c07580ea91b
This is what I have right now and I believe it should work like this.
HTML:
<div class="analogClock">
<div class="hours-container" id="pointer">
<div class="hours"></div>
</div>
<div class="minutes-container" id="pointer">
<div class="minutes"></div>
</div>
<div class="second-container" id="pointer">
<div class="seconds"></div>
</div>
</div>
CSS:
.analogClock
border-radius: 50%;
background-color: #11052B;
height: 20em;
width: 20em;
position: relative;
.second-container, .minutes-container, .hours-container
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
.hours
background-color: #E83063;
height: 20%;
left: 50%;
position: absolute;
top: 50%;
transform-origin: 50% 100%;
width: 2.5%;
border-radius: 50px;
.minutes
background-color: #6CE4FF;
height: 30%;
left: 50%;
position: absolute;
top: 50%;
transform-origin: 50% 100%;
width: 2%;
border-radius: 50px;
.seconds
background-color: #59FF8C;
height: 40%;
left: 50%;
position: absolute;
top: 50%;
transform-origin: 50% 100%;
width: 1%;
z-index: 8;
border-radius: 50px;
.hours-container
animation: rotate 43200s infinite steps(12);
.minutes-container
animation: rotate 3600s infinite steps(60);
.second-container
animation: rotate 60s infinite steps(60);
@keyframes rotate
100% transform: rotateZ(360deg);
JS:
//Analog clock
const hourPointer = document.querySelector('.hours-container');
const minutePointer = document.querySelector('.minutes-container');
const secondPointer = document.querySelector('.second-container');
function analogClock()
var date = new Date();
var seconds = date.getSeconds();
var minutes = date.getMinutes();
var hours = date.getHours();
let hrPosition = hours*360/12 + ((minutes * 360/60)/12) ;
let minPosition = (minutes * 360/60) + (seconds* 360/60)/60;
let secPosition = seconds * 360/60;
hourPointer.getElementsByClassName.transform = 'rotate(' + hrPosition + 'deg)';
minutePointer.getElementsByClassName.transform = 'rotate(' + minPosition + 'deg)';
secondPointer.getElementsByClassName.transform = 'rotate(' + secPosition + 'deg)';
var interval = setInterval(analogClock, 500)
I want the hands to point at the current time, but they start from the bottom no matter what time it is.
Thanks for your time!
javascript
Please may I have the css and html for this? I am working on a fix for you but want to give you a correct, tested answer.
– Jason Is My Name
Mar 25 at 10:31
Ofcourse! I'll update the post in a sec.
– Jeroen
Mar 25 at 11:05
shouldn't behours*360/12
change tohours * (360/12)
?
– Eduard Jacko
Mar 25 at 11:13
Make id="pointer" a class.
– Jason Is My Name
Mar 25 at 11:15
add a comment |
I'm trying to make a clock in javascript. I can't figure out how to set the value of rotate() equal to the degree of the current time.
I've tried some methods.
I've looked at these tutorials:
- https://cssanimation.rocks/clocks/
- https://medium.com/@abhi95.saxena/make-an-analog-clock-using-javascript-7c07580ea91b
This is what I have right now and I believe it should work like this.
HTML:
<div class="analogClock">
<div class="hours-container" id="pointer">
<div class="hours"></div>
</div>
<div class="minutes-container" id="pointer">
<div class="minutes"></div>
</div>
<div class="second-container" id="pointer">
<div class="seconds"></div>
</div>
</div>
CSS:
.analogClock
border-radius: 50%;
background-color: #11052B;
height: 20em;
width: 20em;
position: relative;
.second-container, .minutes-container, .hours-container
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
.hours
background-color: #E83063;
height: 20%;
left: 50%;
position: absolute;
top: 50%;
transform-origin: 50% 100%;
width: 2.5%;
border-radius: 50px;
.minutes
background-color: #6CE4FF;
height: 30%;
left: 50%;
position: absolute;
top: 50%;
transform-origin: 50% 100%;
width: 2%;
border-radius: 50px;
.seconds
background-color: #59FF8C;
height: 40%;
left: 50%;
position: absolute;
top: 50%;
transform-origin: 50% 100%;
width: 1%;
z-index: 8;
border-radius: 50px;
.hours-container
animation: rotate 43200s infinite steps(12);
.minutes-container
animation: rotate 3600s infinite steps(60);
.second-container
animation: rotate 60s infinite steps(60);
@keyframes rotate
100% transform: rotateZ(360deg);
JS:
//Analog clock
const hourPointer = document.querySelector('.hours-container');
const minutePointer = document.querySelector('.minutes-container');
const secondPointer = document.querySelector('.second-container');
function analogClock()
var date = new Date();
var seconds = date.getSeconds();
var minutes = date.getMinutes();
var hours = date.getHours();
let hrPosition = hours*360/12 + ((minutes * 360/60)/12) ;
let minPosition = (minutes * 360/60) + (seconds* 360/60)/60;
let secPosition = seconds * 360/60;
hourPointer.getElementsByClassName.transform = 'rotate(' + hrPosition + 'deg)';
minutePointer.getElementsByClassName.transform = 'rotate(' + minPosition + 'deg)';
secondPointer.getElementsByClassName.transform = 'rotate(' + secPosition + 'deg)';
var interval = setInterval(analogClock, 500)
I want the hands to point at the current time, but they start from the bottom no matter what time it is.
Thanks for your time!
javascript
I'm trying to make a clock in javascript. I can't figure out how to set the value of rotate() equal to the degree of the current time.
I've tried some methods.
I've looked at these tutorials:
- https://cssanimation.rocks/clocks/
- https://medium.com/@abhi95.saxena/make-an-analog-clock-using-javascript-7c07580ea91b
This is what I have right now and I believe it should work like this.
HTML:
<div class="analogClock">
<div class="hours-container" id="pointer">
<div class="hours"></div>
</div>
<div class="minutes-container" id="pointer">
<div class="minutes"></div>
</div>
<div class="second-container" id="pointer">
<div class="seconds"></div>
</div>
</div>
CSS:
.analogClock
border-radius: 50%;
background-color: #11052B;
height: 20em;
width: 20em;
position: relative;
.second-container, .minutes-container, .hours-container
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
.hours
background-color: #E83063;
height: 20%;
left: 50%;
position: absolute;
top: 50%;
transform-origin: 50% 100%;
width: 2.5%;
border-radius: 50px;
.minutes
background-color: #6CE4FF;
height: 30%;
left: 50%;
position: absolute;
top: 50%;
transform-origin: 50% 100%;
width: 2%;
border-radius: 50px;
.seconds
background-color: #59FF8C;
height: 40%;
left: 50%;
position: absolute;
top: 50%;
transform-origin: 50% 100%;
width: 1%;
z-index: 8;
border-radius: 50px;
.hours-container
animation: rotate 43200s infinite steps(12);
.minutes-container
animation: rotate 3600s infinite steps(60);
.second-container
animation: rotate 60s infinite steps(60);
@keyframes rotate
100% transform: rotateZ(360deg);
JS:
//Analog clock
const hourPointer = document.querySelector('.hours-container');
const minutePointer = document.querySelector('.minutes-container');
const secondPointer = document.querySelector('.second-container');
function analogClock()
var date = new Date();
var seconds = date.getSeconds();
var minutes = date.getMinutes();
var hours = date.getHours();
let hrPosition = hours*360/12 + ((minutes * 360/60)/12) ;
let minPosition = (minutes * 360/60) + (seconds* 360/60)/60;
let secPosition = seconds * 360/60;
hourPointer.getElementsByClassName.transform = 'rotate(' + hrPosition + 'deg)';
minutePointer.getElementsByClassName.transform = 'rotate(' + minPosition + 'deg)';
secondPointer.getElementsByClassName.transform = 'rotate(' + secPosition + 'deg)';
var interval = setInterval(analogClock, 500)
I want the hands to point at the current time, but they start from the bottom no matter what time it is.
Thanks for your time!
javascript
javascript
edited Mar 25 at 11:09
Jeroen
asked Mar 25 at 8:46
JeroenJeroen
5210
5210
Please may I have the css and html for this? I am working on a fix for you but want to give you a correct, tested answer.
– Jason Is My Name
Mar 25 at 10:31
Ofcourse! I'll update the post in a sec.
– Jeroen
Mar 25 at 11:05
shouldn't behours*360/12
change tohours * (360/12)
?
– Eduard Jacko
Mar 25 at 11:13
Make id="pointer" a class.
– Jason Is My Name
Mar 25 at 11:15
add a comment |
Please may I have the css and html for this? I am working on a fix for you but want to give you a correct, tested answer.
– Jason Is My Name
Mar 25 at 10:31
Ofcourse! I'll update the post in a sec.
– Jeroen
Mar 25 at 11:05
shouldn't behours*360/12
change tohours * (360/12)
?
– Eduard Jacko
Mar 25 at 11:13
Make id="pointer" a class.
– Jason Is My Name
Mar 25 at 11:15
Please may I have the css and html for this? I am working on a fix for you but want to give you a correct, tested answer.
– Jason Is My Name
Mar 25 at 10:31
Please may I have the css and html for this? I am working on a fix for you but want to give you a correct, tested answer.
– Jason Is My Name
Mar 25 at 10:31
Ofcourse! I'll update the post in a sec.
– Jeroen
Mar 25 at 11:05
Ofcourse! I'll update the post in a sec.
– Jeroen
Mar 25 at 11:05
shouldn't be
hours*360/12
change to hours * (360/12)
?– Eduard Jacko
Mar 25 at 11:13
shouldn't be
hours*360/12
change to hours * (360/12)
?– Eduard Jacko
Mar 25 at 11:13
Make id="pointer" a class.
– Jason Is My Name
Mar 25 at 11:15
Make id="pointer" a class.
– Jason Is My Name
Mar 25 at 11:15
add a comment |
1 Answer
1
active
oldest
votes
I have attempted to get you as much in here as possible, you should see a fully working clock. It's not been done too different from your current version.
(function ($)
var secondHand = $('.second-hand');
var minuteHand = $('.minute-hand');
var hourHand = $('.hour-hand');
function analogClock()
var date = new Date();
var seconds = date.getSeconds();
var minutes = date.getMinutes();
var hours = date.getHours();
//console.log(date);
//console.log(seconds);
//console.log(minutes);
//console.log(hours);
seconds = (360 / 100) * ((seconds / 60) * 100);
minutes = (360 / 100) * ((minutes / 60) * 100);
hours = (360 / 100) * ((hours / 12) * 100);
var secondsAngle = seconds;
var minutesAngle = minutes;
var hoursAngle = hours;
//console.log(secondsAngle);
//console.log(minutesAngle);
//console.log(hoursAngle);
secondHand.css(
'-webkit-transform' : 'rotate('+ secondsAngle +'deg)',
'-moz-transform' : 'rotate('+ secondsAngle +'deg)',
'-ms-transform' : 'rotate('+ secondsAngle +'deg)',
'transform' : 'rotate('+ secondsAngle +'deg)'
);
minuteHand.css(
'-webkit-transform' : 'rotate('+ minutesAngle +'deg)',
'-moz-transform' : 'rotate('+ minutesAngle +'deg)',
'-ms-transform' : 'rotate('+ minutesAngle +'deg)',
'transform' : 'rotate('+ minutesAngle +'deg)'
);
hourHand.css(
'-webkit-transform' : 'rotate('+ hoursAngle +'deg)',
'-moz-transform' : 'rotate('+ hoursAngle +'deg)',
'-ms-transform' : 'rotate('+ hoursAngle +'deg)',
'transform' : 'rotate('+ hoursAngle +'deg)'
);
setInterval(function()
analogClock();
, 1000);
)(jQuery);
*
margin: 0;
padding: 0;
box-sizing: border-box;
.clock
width: 300px;
height: 300px;
margin: 0 auto;
padding: 50px;
position: relative;
background-color: purple;
.clock-face
width: 100%;
height: 100%;
margin: 0 auto;
position: relative;
.hand
height: 100px;
position: absolute;
left: 50%;
-ms-transform: translate(-50%, -50%);
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
transform-origin: 50% 100%;
display: block;
.second-hand
width: 5px;
z-index: 3;
.sec-hand
height: 100px;
background-color: red;
.minute-hand
width: 6px;
z-index: 2;
.min-hand
height: 80px;
margin-top: 20px;
background-color: green;
.hour-hand
width: 7px;
z-index: 1;
.hr-hand
height: 60px;
margin-top: 40px;
background-color: black;
.single-hand
width: 100%;
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="clock">
<div class="clock-face">
<div class="second-hand hand">
<div class="sec-hand single-hand"></div>
</div>
<div class="minute-hand hand">
<div class="min-hand single-hand"></div>
</div>
<div class="hour-hand hand">
<div class="hr-hand single-hand"></div>
</div>
</div>
</div>
- Just updated to order the hands (z-index) and change their length...
The Math:
seconds = (360 / 100) * ((seconds / 60) * 100);
minutes = (360 / 100) * ((minutes / 60) * 100);
hours = (360 / 100) * ((hours / 12) * 100);s
(360 / 100): So for all of the time variables, there is 360deg of possible rotation.
We divide by 100, to give us a single percent of the clocks face.
a * b: We now can multiply this by a percentage of the clock (the math above) to represent how far in degrees we will need to rotate the hand.
((seconds / 60) * 100): We need to then create a value that is a percentage of the way through a full rotation.
This can be done by taking the number of seconds, minutes, hours given by the new date(); dividing it by the total possible 60 seconds, 60 minutes, 12 hours.
We then must multiply it by 100% to get a percentage.
The whole result: One seconds worth of rotation * percentage of the way through one full turn.
e.g: 1 second worth of rotation * 50% of the way through a complete minute = 180deg / 30seconds
Hope that makes sense...
Im an idiot, I have started the clock at 3:15:15. Let me fix this.
– Jason Is My Name
Mar 25 at 11:17
1
This has been updated. Hope it helps
– Jason Is My Name
Mar 25 at 11:43
Thanks for taking the time to create such a comprehensive solution Jason! I learned a lot from it! I got a view points I don't understand and if it isn't to much trouble I'd like to get more info about: How the math works u used to get the correct angle and if you could point me to a source where I can see how the ajax and jquery code u used works. You're probably a busy man so please don't feel obligated to answer my questions.
– Jeroen
Mar 25 at 12:53
1
No problemo @Jeroen, glad you like it. You can see the math explained at the tail of my answer.
– Jason Is My Name
Mar 25 at 12:59
Thank you Jason! I really apreciate it! One last question about the math. Isn't (seconds / 60 * 100) the same as ((seconds / 60) * 100). Or do the inner parenthesis change something?
– Jeroen
Mar 25 at 13:09
|
show 3 more comments
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55334022%2fhow-to-set-rotate-value-to-match-current-time%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I have attempted to get you as much in here as possible, you should see a fully working clock. It's not been done too different from your current version.
(function ($)
var secondHand = $('.second-hand');
var minuteHand = $('.minute-hand');
var hourHand = $('.hour-hand');
function analogClock()
var date = new Date();
var seconds = date.getSeconds();
var minutes = date.getMinutes();
var hours = date.getHours();
//console.log(date);
//console.log(seconds);
//console.log(minutes);
//console.log(hours);
seconds = (360 / 100) * ((seconds / 60) * 100);
minutes = (360 / 100) * ((minutes / 60) * 100);
hours = (360 / 100) * ((hours / 12) * 100);
var secondsAngle = seconds;
var minutesAngle = minutes;
var hoursAngle = hours;
//console.log(secondsAngle);
//console.log(minutesAngle);
//console.log(hoursAngle);
secondHand.css(
'-webkit-transform' : 'rotate('+ secondsAngle +'deg)',
'-moz-transform' : 'rotate('+ secondsAngle +'deg)',
'-ms-transform' : 'rotate('+ secondsAngle +'deg)',
'transform' : 'rotate('+ secondsAngle +'deg)'
);
minuteHand.css(
'-webkit-transform' : 'rotate('+ minutesAngle +'deg)',
'-moz-transform' : 'rotate('+ minutesAngle +'deg)',
'-ms-transform' : 'rotate('+ minutesAngle +'deg)',
'transform' : 'rotate('+ minutesAngle +'deg)'
);
hourHand.css(
'-webkit-transform' : 'rotate('+ hoursAngle +'deg)',
'-moz-transform' : 'rotate('+ hoursAngle +'deg)',
'-ms-transform' : 'rotate('+ hoursAngle +'deg)',
'transform' : 'rotate('+ hoursAngle +'deg)'
);
setInterval(function()
analogClock();
, 1000);
)(jQuery);
*
margin: 0;
padding: 0;
box-sizing: border-box;
.clock
width: 300px;
height: 300px;
margin: 0 auto;
padding: 50px;
position: relative;
background-color: purple;
.clock-face
width: 100%;
height: 100%;
margin: 0 auto;
position: relative;
.hand
height: 100px;
position: absolute;
left: 50%;
-ms-transform: translate(-50%, -50%);
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
transform-origin: 50% 100%;
display: block;
.second-hand
width: 5px;
z-index: 3;
.sec-hand
height: 100px;
background-color: red;
.minute-hand
width: 6px;
z-index: 2;
.min-hand
height: 80px;
margin-top: 20px;
background-color: green;
.hour-hand
width: 7px;
z-index: 1;
.hr-hand
height: 60px;
margin-top: 40px;
background-color: black;
.single-hand
width: 100%;
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="clock">
<div class="clock-face">
<div class="second-hand hand">
<div class="sec-hand single-hand"></div>
</div>
<div class="minute-hand hand">
<div class="min-hand single-hand"></div>
</div>
<div class="hour-hand hand">
<div class="hr-hand single-hand"></div>
</div>
</div>
</div>
- Just updated to order the hands (z-index) and change their length...
The Math:
seconds = (360 / 100) * ((seconds / 60) * 100);
minutes = (360 / 100) * ((minutes / 60) * 100);
hours = (360 / 100) * ((hours / 12) * 100);s
(360 / 100): So for all of the time variables, there is 360deg of possible rotation.
We divide by 100, to give us a single percent of the clocks face.
a * b: We now can multiply this by a percentage of the clock (the math above) to represent how far in degrees we will need to rotate the hand.
((seconds / 60) * 100): We need to then create a value that is a percentage of the way through a full rotation.
This can be done by taking the number of seconds, minutes, hours given by the new date(); dividing it by the total possible 60 seconds, 60 minutes, 12 hours.
We then must multiply it by 100% to get a percentage.
The whole result: One seconds worth of rotation * percentage of the way through one full turn.
e.g: 1 second worth of rotation * 50% of the way through a complete minute = 180deg / 30seconds
Hope that makes sense...
Im an idiot, I have started the clock at 3:15:15. Let me fix this.
– Jason Is My Name
Mar 25 at 11:17
1
This has been updated. Hope it helps
– Jason Is My Name
Mar 25 at 11:43
Thanks for taking the time to create such a comprehensive solution Jason! I learned a lot from it! I got a view points I don't understand and if it isn't to much trouble I'd like to get more info about: How the math works u used to get the correct angle and if you could point me to a source where I can see how the ajax and jquery code u used works. You're probably a busy man so please don't feel obligated to answer my questions.
– Jeroen
Mar 25 at 12:53
1
No problemo @Jeroen, glad you like it. You can see the math explained at the tail of my answer.
– Jason Is My Name
Mar 25 at 12:59
Thank you Jason! I really apreciate it! One last question about the math. Isn't (seconds / 60 * 100) the same as ((seconds / 60) * 100). Or do the inner parenthesis change something?
– Jeroen
Mar 25 at 13:09
|
show 3 more comments
I have attempted to get you as much in here as possible, you should see a fully working clock. It's not been done too different from your current version.
(function ($)
var secondHand = $('.second-hand');
var minuteHand = $('.minute-hand');
var hourHand = $('.hour-hand');
function analogClock()
var date = new Date();
var seconds = date.getSeconds();
var minutes = date.getMinutes();
var hours = date.getHours();
//console.log(date);
//console.log(seconds);
//console.log(minutes);
//console.log(hours);
seconds = (360 / 100) * ((seconds / 60) * 100);
minutes = (360 / 100) * ((minutes / 60) * 100);
hours = (360 / 100) * ((hours / 12) * 100);
var secondsAngle = seconds;
var minutesAngle = minutes;
var hoursAngle = hours;
//console.log(secondsAngle);
//console.log(minutesAngle);
//console.log(hoursAngle);
secondHand.css(
'-webkit-transform' : 'rotate('+ secondsAngle +'deg)',
'-moz-transform' : 'rotate('+ secondsAngle +'deg)',
'-ms-transform' : 'rotate('+ secondsAngle +'deg)',
'transform' : 'rotate('+ secondsAngle +'deg)'
);
minuteHand.css(
'-webkit-transform' : 'rotate('+ minutesAngle +'deg)',
'-moz-transform' : 'rotate('+ minutesAngle +'deg)',
'-ms-transform' : 'rotate('+ minutesAngle +'deg)',
'transform' : 'rotate('+ minutesAngle +'deg)'
);
hourHand.css(
'-webkit-transform' : 'rotate('+ hoursAngle +'deg)',
'-moz-transform' : 'rotate('+ hoursAngle +'deg)',
'-ms-transform' : 'rotate('+ hoursAngle +'deg)',
'transform' : 'rotate('+ hoursAngle +'deg)'
);
setInterval(function()
analogClock();
, 1000);
)(jQuery);
*
margin: 0;
padding: 0;
box-sizing: border-box;
.clock
width: 300px;
height: 300px;
margin: 0 auto;
padding: 50px;
position: relative;
background-color: purple;
.clock-face
width: 100%;
height: 100%;
margin: 0 auto;
position: relative;
.hand
height: 100px;
position: absolute;
left: 50%;
-ms-transform: translate(-50%, -50%);
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
transform-origin: 50% 100%;
display: block;
.second-hand
width: 5px;
z-index: 3;
.sec-hand
height: 100px;
background-color: red;
.minute-hand
width: 6px;
z-index: 2;
.min-hand
height: 80px;
margin-top: 20px;
background-color: green;
.hour-hand
width: 7px;
z-index: 1;
.hr-hand
height: 60px;
margin-top: 40px;
background-color: black;
.single-hand
width: 100%;
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="clock">
<div class="clock-face">
<div class="second-hand hand">
<div class="sec-hand single-hand"></div>
</div>
<div class="minute-hand hand">
<div class="min-hand single-hand"></div>
</div>
<div class="hour-hand hand">
<div class="hr-hand single-hand"></div>
</div>
</div>
</div>
- Just updated to order the hands (z-index) and change their length...
The Math:
seconds = (360 / 100) * ((seconds / 60) * 100);
minutes = (360 / 100) * ((minutes / 60) * 100);
hours = (360 / 100) * ((hours / 12) * 100);s
(360 / 100): So for all of the time variables, there is 360deg of possible rotation.
We divide by 100, to give us a single percent of the clocks face.
a * b: We now can multiply this by a percentage of the clock (the math above) to represent how far in degrees we will need to rotate the hand.
((seconds / 60) * 100): We need to then create a value that is a percentage of the way through a full rotation.
This can be done by taking the number of seconds, minutes, hours given by the new date(); dividing it by the total possible 60 seconds, 60 minutes, 12 hours.
We then must multiply it by 100% to get a percentage.
The whole result: One seconds worth of rotation * percentage of the way through one full turn.
e.g: 1 second worth of rotation * 50% of the way through a complete minute = 180deg / 30seconds
Hope that makes sense...
Im an idiot, I have started the clock at 3:15:15. Let me fix this.
– Jason Is My Name
Mar 25 at 11:17
1
This has been updated. Hope it helps
– Jason Is My Name
Mar 25 at 11:43
Thanks for taking the time to create such a comprehensive solution Jason! I learned a lot from it! I got a view points I don't understand and if it isn't to much trouble I'd like to get more info about: How the math works u used to get the correct angle and if you could point me to a source where I can see how the ajax and jquery code u used works. You're probably a busy man so please don't feel obligated to answer my questions.
– Jeroen
Mar 25 at 12:53
1
No problemo @Jeroen, glad you like it. You can see the math explained at the tail of my answer.
– Jason Is My Name
Mar 25 at 12:59
Thank you Jason! I really apreciate it! One last question about the math. Isn't (seconds / 60 * 100) the same as ((seconds / 60) * 100). Or do the inner parenthesis change something?
– Jeroen
Mar 25 at 13:09
|
show 3 more comments
I have attempted to get you as much in here as possible, you should see a fully working clock. It's not been done too different from your current version.
(function ($)
var secondHand = $('.second-hand');
var minuteHand = $('.minute-hand');
var hourHand = $('.hour-hand');
function analogClock()
var date = new Date();
var seconds = date.getSeconds();
var minutes = date.getMinutes();
var hours = date.getHours();
//console.log(date);
//console.log(seconds);
//console.log(minutes);
//console.log(hours);
seconds = (360 / 100) * ((seconds / 60) * 100);
minutes = (360 / 100) * ((minutes / 60) * 100);
hours = (360 / 100) * ((hours / 12) * 100);
var secondsAngle = seconds;
var minutesAngle = minutes;
var hoursAngle = hours;
//console.log(secondsAngle);
//console.log(minutesAngle);
//console.log(hoursAngle);
secondHand.css(
'-webkit-transform' : 'rotate('+ secondsAngle +'deg)',
'-moz-transform' : 'rotate('+ secondsAngle +'deg)',
'-ms-transform' : 'rotate('+ secondsAngle +'deg)',
'transform' : 'rotate('+ secondsAngle +'deg)'
);
minuteHand.css(
'-webkit-transform' : 'rotate('+ minutesAngle +'deg)',
'-moz-transform' : 'rotate('+ minutesAngle +'deg)',
'-ms-transform' : 'rotate('+ minutesAngle +'deg)',
'transform' : 'rotate('+ minutesAngle +'deg)'
);
hourHand.css(
'-webkit-transform' : 'rotate('+ hoursAngle +'deg)',
'-moz-transform' : 'rotate('+ hoursAngle +'deg)',
'-ms-transform' : 'rotate('+ hoursAngle +'deg)',
'transform' : 'rotate('+ hoursAngle +'deg)'
);
setInterval(function()
analogClock();
, 1000);
)(jQuery);
*
margin: 0;
padding: 0;
box-sizing: border-box;
.clock
width: 300px;
height: 300px;
margin: 0 auto;
padding: 50px;
position: relative;
background-color: purple;
.clock-face
width: 100%;
height: 100%;
margin: 0 auto;
position: relative;
.hand
height: 100px;
position: absolute;
left: 50%;
-ms-transform: translate(-50%, -50%);
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
transform-origin: 50% 100%;
display: block;
.second-hand
width: 5px;
z-index: 3;
.sec-hand
height: 100px;
background-color: red;
.minute-hand
width: 6px;
z-index: 2;
.min-hand
height: 80px;
margin-top: 20px;
background-color: green;
.hour-hand
width: 7px;
z-index: 1;
.hr-hand
height: 60px;
margin-top: 40px;
background-color: black;
.single-hand
width: 100%;
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="clock">
<div class="clock-face">
<div class="second-hand hand">
<div class="sec-hand single-hand"></div>
</div>
<div class="minute-hand hand">
<div class="min-hand single-hand"></div>
</div>
<div class="hour-hand hand">
<div class="hr-hand single-hand"></div>
</div>
</div>
</div>
- Just updated to order the hands (z-index) and change their length...
The Math:
seconds = (360 / 100) * ((seconds / 60) * 100);
minutes = (360 / 100) * ((minutes / 60) * 100);
hours = (360 / 100) * ((hours / 12) * 100);s
(360 / 100): So for all of the time variables, there is 360deg of possible rotation.
We divide by 100, to give us a single percent of the clocks face.
a * b: We now can multiply this by a percentage of the clock (the math above) to represent how far in degrees we will need to rotate the hand.
((seconds / 60) * 100): We need to then create a value that is a percentage of the way through a full rotation.
This can be done by taking the number of seconds, minutes, hours given by the new date(); dividing it by the total possible 60 seconds, 60 minutes, 12 hours.
We then must multiply it by 100% to get a percentage.
The whole result: One seconds worth of rotation * percentage of the way through one full turn.
e.g: 1 second worth of rotation * 50% of the way through a complete minute = 180deg / 30seconds
Hope that makes sense...
I have attempted to get you as much in here as possible, you should see a fully working clock. It's not been done too different from your current version.
(function ($)
var secondHand = $('.second-hand');
var minuteHand = $('.minute-hand');
var hourHand = $('.hour-hand');
function analogClock()
var date = new Date();
var seconds = date.getSeconds();
var minutes = date.getMinutes();
var hours = date.getHours();
//console.log(date);
//console.log(seconds);
//console.log(minutes);
//console.log(hours);
seconds = (360 / 100) * ((seconds / 60) * 100);
minutes = (360 / 100) * ((minutes / 60) * 100);
hours = (360 / 100) * ((hours / 12) * 100);
var secondsAngle = seconds;
var minutesAngle = minutes;
var hoursAngle = hours;
//console.log(secondsAngle);
//console.log(minutesAngle);
//console.log(hoursAngle);
secondHand.css(
'-webkit-transform' : 'rotate('+ secondsAngle +'deg)',
'-moz-transform' : 'rotate('+ secondsAngle +'deg)',
'-ms-transform' : 'rotate('+ secondsAngle +'deg)',
'transform' : 'rotate('+ secondsAngle +'deg)'
);
minuteHand.css(
'-webkit-transform' : 'rotate('+ minutesAngle +'deg)',
'-moz-transform' : 'rotate('+ minutesAngle +'deg)',
'-ms-transform' : 'rotate('+ minutesAngle +'deg)',
'transform' : 'rotate('+ minutesAngle +'deg)'
);
hourHand.css(
'-webkit-transform' : 'rotate('+ hoursAngle +'deg)',
'-moz-transform' : 'rotate('+ hoursAngle +'deg)',
'-ms-transform' : 'rotate('+ hoursAngle +'deg)',
'transform' : 'rotate('+ hoursAngle +'deg)'
);
setInterval(function()
analogClock();
, 1000);
)(jQuery);
*
margin: 0;
padding: 0;
box-sizing: border-box;
.clock
width: 300px;
height: 300px;
margin: 0 auto;
padding: 50px;
position: relative;
background-color: purple;
.clock-face
width: 100%;
height: 100%;
margin: 0 auto;
position: relative;
.hand
height: 100px;
position: absolute;
left: 50%;
-ms-transform: translate(-50%, -50%);
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
transform-origin: 50% 100%;
display: block;
.second-hand
width: 5px;
z-index: 3;
.sec-hand
height: 100px;
background-color: red;
.minute-hand
width: 6px;
z-index: 2;
.min-hand
height: 80px;
margin-top: 20px;
background-color: green;
.hour-hand
width: 7px;
z-index: 1;
.hr-hand
height: 60px;
margin-top: 40px;
background-color: black;
.single-hand
width: 100%;
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="clock">
<div class="clock-face">
<div class="second-hand hand">
<div class="sec-hand single-hand"></div>
</div>
<div class="minute-hand hand">
<div class="min-hand single-hand"></div>
</div>
<div class="hour-hand hand">
<div class="hr-hand single-hand"></div>
</div>
</div>
</div>
- Just updated to order the hands (z-index) and change their length...
The Math:
seconds = (360 / 100) * ((seconds / 60) * 100);
minutes = (360 / 100) * ((minutes / 60) * 100);
hours = (360 / 100) * ((hours / 12) * 100);s
(360 / 100): So for all of the time variables, there is 360deg of possible rotation.
We divide by 100, to give us a single percent of the clocks face.
a * b: We now can multiply this by a percentage of the clock (the math above) to represent how far in degrees we will need to rotate the hand.
((seconds / 60) * 100): We need to then create a value that is a percentage of the way through a full rotation.
This can be done by taking the number of seconds, minutes, hours given by the new date(); dividing it by the total possible 60 seconds, 60 minutes, 12 hours.
We then must multiply it by 100% to get a percentage.
The whole result: One seconds worth of rotation * percentage of the way through one full turn.
e.g: 1 second worth of rotation * 50% of the way through a complete minute = 180deg / 30seconds
Hope that makes sense...
(function ($)
var secondHand = $('.second-hand');
var minuteHand = $('.minute-hand');
var hourHand = $('.hour-hand');
function analogClock()
var date = new Date();
var seconds = date.getSeconds();
var minutes = date.getMinutes();
var hours = date.getHours();
//console.log(date);
//console.log(seconds);
//console.log(minutes);
//console.log(hours);
seconds = (360 / 100) * ((seconds / 60) * 100);
minutes = (360 / 100) * ((minutes / 60) * 100);
hours = (360 / 100) * ((hours / 12) * 100);
var secondsAngle = seconds;
var minutesAngle = minutes;
var hoursAngle = hours;
//console.log(secondsAngle);
//console.log(minutesAngle);
//console.log(hoursAngle);
secondHand.css(
'-webkit-transform' : 'rotate('+ secondsAngle +'deg)',
'-moz-transform' : 'rotate('+ secondsAngle +'deg)',
'-ms-transform' : 'rotate('+ secondsAngle +'deg)',
'transform' : 'rotate('+ secondsAngle +'deg)'
);
minuteHand.css(
'-webkit-transform' : 'rotate('+ minutesAngle +'deg)',
'-moz-transform' : 'rotate('+ minutesAngle +'deg)',
'-ms-transform' : 'rotate('+ minutesAngle +'deg)',
'transform' : 'rotate('+ minutesAngle +'deg)'
);
hourHand.css(
'-webkit-transform' : 'rotate('+ hoursAngle +'deg)',
'-moz-transform' : 'rotate('+ hoursAngle +'deg)',
'-ms-transform' : 'rotate('+ hoursAngle +'deg)',
'transform' : 'rotate('+ hoursAngle +'deg)'
);
setInterval(function()
analogClock();
, 1000);
)(jQuery);
*
margin: 0;
padding: 0;
box-sizing: border-box;
.clock
width: 300px;
height: 300px;
margin: 0 auto;
padding: 50px;
position: relative;
background-color: purple;
.clock-face
width: 100%;
height: 100%;
margin: 0 auto;
position: relative;
.hand
height: 100px;
position: absolute;
left: 50%;
-ms-transform: translate(-50%, -50%);
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
transform-origin: 50% 100%;
display: block;
.second-hand
width: 5px;
z-index: 3;
.sec-hand
height: 100px;
background-color: red;
.minute-hand
width: 6px;
z-index: 2;
.min-hand
height: 80px;
margin-top: 20px;
background-color: green;
.hour-hand
width: 7px;
z-index: 1;
.hr-hand
height: 60px;
margin-top: 40px;
background-color: black;
.single-hand
width: 100%;
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="clock">
<div class="clock-face">
<div class="second-hand hand">
<div class="sec-hand single-hand"></div>
</div>
<div class="minute-hand hand">
<div class="min-hand single-hand"></div>
</div>
<div class="hour-hand hand">
<div class="hr-hand single-hand"></div>
</div>
</div>
</div>
(function ($)
var secondHand = $('.second-hand');
var minuteHand = $('.minute-hand');
var hourHand = $('.hour-hand');
function analogClock()
var date = new Date();
var seconds = date.getSeconds();
var minutes = date.getMinutes();
var hours = date.getHours();
//console.log(date);
//console.log(seconds);
//console.log(minutes);
//console.log(hours);
seconds = (360 / 100) * ((seconds / 60) * 100);
minutes = (360 / 100) * ((minutes / 60) * 100);
hours = (360 / 100) * ((hours / 12) * 100);
var secondsAngle = seconds;
var minutesAngle = minutes;
var hoursAngle = hours;
//console.log(secondsAngle);
//console.log(minutesAngle);
//console.log(hoursAngle);
secondHand.css(
'-webkit-transform' : 'rotate('+ secondsAngle +'deg)',
'-moz-transform' : 'rotate('+ secondsAngle +'deg)',
'-ms-transform' : 'rotate('+ secondsAngle +'deg)',
'transform' : 'rotate('+ secondsAngle +'deg)'
);
minuteHand.css(
'-webkit-transform' : 'rotate('+ minutesAngle +'deg)',
'-moz-transform' : 'rotate('+ minutesAngle +'deg)',
'-ms-transform' : 'rotate('+ minutesAngle +'deg)',
'transform' : 'rotate('+ minutesAngle +'deg)'
);
hourHand.css(
'-webkit-transform' : 'rotate('+ hoursAngle +'deg)',
'-moz-transform' : 'rotate('+ hoursAngle +'deg)',
'-ms-transform' : 'rotate('+ hoursAngle +'deg)',
'transform' : 'rotate('+ hoursAngle +'deg)'
);
setInterval(function()
analogClock();
, 1000);
)(jQuery);
*
margin: 0;
padding: 0;
box-sizing: border-box;
.clock
width: 300px;
height: 300px;
margin: 0 auto;
padding: 50px;
position: relative;
background-color: purple;
.clock-face
width: 100%;
height: 100%;
margin: 0 auto;
position: relative;
.hand
height: 100px;
position: absolute;
left: 50%;
-ms-transform: translate(-50%, -50%);
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
transform-origin: 50% 100%;
display: block;
.second-hand
width: 5px;
z-index: 3;
.sec-hand
height: 100px;
background-color: red;
.minute-hand
width: 6px;
z-index: 2;
.min-hand
height: 80px;
margin-top: 20px;
background-color: green;
.hour-hand
width: 7px;
z-index: 1;
.hr-hand
height: 60px;
margin-top: 40px;
background-color: black;
.single-hand
width: 100%;
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="clock">
<div class="clock-face">
<div class="second-hand hand">
<div class="sec-hand single-hand"></div>
</div>
<div class="minute-hand hand">
<div class="min-hand single-hand"></div>
</div>
<div class="hour-hand hand">
<div class="hr-hand single-hand"></div>
</div>
</div>
</div>
edited Mar 25 at 13:16
answered Mar 25 at 11:10
Jason Is My NameJason Is My Name
149116
149116
Im an idiot, I have started the clock at 3:15:15. Let me fix this.
– Jason Is My Name
Mar 25 at 11:17
1
This has been updated. Hope it helps
– Jason Is My Name
Mar 25 at 11:43
Thanks for taking the time to create such a comprehensive solution Jason! I learned a lot from it! I got a view points I don't understand and if it isn't to much trouble I'd like to get more info about: How the math works u used to get the correct angle and if you could point me to a source where I can see how the ajax and jquery code u used works. You're probably a busy man so please don't feel obligated to answer my questions.
– Jeroen
Mar 25 at 12:53
1
No problemo @Jeroen, glad you like it. You can see the math explained at the tail of my answer.
– Jason Is My Name
Mar 25 at 12:59
Thank you Jason! I really apreciate it! One last question about the math. Isn't (seconds / 60 * 100) the same as ((seconds / 60) * 100). Or do the inner parenthesis change something?
– Jeroen
Mar 25 at 13:09
|
show 3 more comments
Im an idiot, I have started the clock at 3:15:15. Let me fix this.
– Jason Is My Name
Mar 25 at 11:17
1
This has been updated. Hope it helps
– Jason Is My Name
Mar 25 at 11:43
Thanks for taking the time to create such a comprehensive solution Jason! I learned a lot from it! I got a view points I don't understand and if it isn't to much trouble I'd like to get more info about: How the math works u used to get the correct angle and if you could point me to a source where I can see how the ajax and jquery code u used works. You're probably a busy man so please don't feel obligated to answer my questions.
– Jeroen
Mar 25 at 12:53
1
No problemo @Jeroen, glad you like it. You can see the math explained at the tail of my answer.
– Jason Is My Name
Mar 25 at 12:59
Thank you Jason! I really apreciate it! One last question about the math. Isn't (seconds / 60 * 100) the same as ((seconds / 60) * 100). Or do the inner parenthesis change something?
– Jeroen
Mar 25 at 13:09
Im an idiot, I have started the clock at 3:15:15. Let me fix this.
– Jason Is My Name
Mar 25 at 11:17
Im an idiot, I have started the clock at 3:15:15. Let me fix this.
– Jason Is My Name
Mar 25 at 11:17
1
1
This has been updated. Hope it helps
– Jason Is My Name
Mar 25 at 11:43
This has been updated. Hope it helps
– Jason Is My Name
Mar 25 at 11:43
Thanks for taking the time to create such a comprehensive solution Jason! I learned a lot from it! I got a view points I don't understand and if it isn't to much trouble I'd like to get more info about: How the math works u used to get the correct angle and if you could point me to a source where I can see how the ajax and jquery code u used works. You're probably a busy man so please don't feel obligated to answer my questions.
– Jeroen
Mar 25 at 12:53
Thanks for taking the time to create such a comprehensive solution Jason! I learned a lot from it! I got a view points I don't understand and if it isn't to much trouble I'd like to get more info about: How the math works u used to get the correct angle and if you could point me to a source where I can see how the ajax and jquery code u used works. You're probably a busy man so please don't feel obligated to answer my questions.
– Jeroen
Mar 25 at 12:53
1
1
No problemo @Jeroen, glad you like it. You can see the math explained at the tail of my answer.
– Jason Is My Name
Mar 25 at 12:59
No problemo @Jeroen, glad you like it. You can see the math explained at the tail of my answer.
– Jason Is My Name
Mar 25 at 12:59
Thank you Jason! I really apreciate it! One last question about the math. Isn't (seconds / 60 * 100) the same as ((seconds / 60) * 100). Or do the inner parenthesis change something?
– Jeroen
Mar 25 at 13:09
Thank you Jason! I really apreciate it! One last question about the math. Isn't (seconds / 60 * 100) the same as ((seconds / 60) * 100). Or do the inner parenthesis change something?
– Jeroen
Mar 25 at 13:09
|
show 3 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55334022%2fhow-to-set-rotate-value-to-match-current-time%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Please may I have the css and html for this? I am working on a fix for you but want to give you a correct, tested answer.
– Jason Is My Name
Mar 25 at 10:31
Ofcourse! I'll update the post in a sec.
– Jeroen
Mar 25 at 11:05
shouldn't be
hours*360/12
change tohours * (360/12)
?– Eduard Jacko
Mar 25 at 11:13
Make id="pointer" a class.
– Jason Is My Name
Mar 25 at 11:15