Skip to content

AndrewJBateman/javascript-clock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⚡ Javascript Clock

GitHub repo size GitHub pull requests GitHub Repo stars GitHub last commit

📄 Table of contents

📚 General info

  • Tutorial Code to create a working clock using just HTML, CSS & javascript.

📷 Screenshots

Example screenshot.

📶 Technologies

💾 Setup

  • Open index.html in browser. If any code is changed the browser needs to be refreshed.

💻 Code Examples

  • function to calculate position of clock hands using new Date().
function setDate() {
  const now = new Date();
  console.log('now', now);

  const seconds = now.getSeconds();
  const secondsDegrees = ((seconds / 60) * 360) + 90;
  secondHand.style.transform = `rotate(${secondsDegrees}deg)`;

  const mins = now.getMinutes();
  const minsDegrees = ((mins / 60) * 360) + ((seconds/60)*6) + 90;
  minsHand.style.transform = `rotate(${minsDegrees}deg)`;

  const hours = now.getHours();
  const hoursDegrees = ((hours / 12) * 360) + ((mins/60)*30) + 90;
  hourHand.style.transform = `rotate(${hoursDegrees}deg)`;
}

🆒 Features

  • Uses cubic-bezier CSS library for ease-in and ease-out of ticking clock hands.

📋 Status & To-Do List

  • Status: Working
  • To-Do: Nothing

👏 Inspiration

📁 License

  • N/A

✉️ Contact

About

📋 Create a clock using vanilla javascript, css and html, from Wes Bos youtube Javascript360 tutorial 2

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors