https://github.com/andrewjbateman/javascript-clock
:clipboard: Create a clock using vanilla javascript, css and html, from Wes Bos youtube Javascript360 tutorial 2
https://github.com/andrewjbateman/javascript-clock
css html javascript javascript30
Last synced: 5 days ago
JSON representation
:clipboard: Create a clock using vanilla javascript, css and html, from Wes Bos youtube Javascript360 tutorial 2
- Host: GitHub
- URL: https://github.com/andrewjbateman/javascript-clock
- Owner: AndrewJBateman
- Created: 2018-11-10T10:16:35.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-03-11T17:35:05.000Z (about 4 years ago)
- Last Synced: 2025-05-17T01:34:28.992Z (11 months ago)
- Topics: css, html, javascript, javascript30
- Language: CSS
- Homepage:
- Size: 4.84 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# :zap: Javascript Clock
* Wes Bos Youtube Tutorial: [We build a CSS + JS Clock in Vanilla JS — #JavaScript30 2/30](https://www.youtube.com/watch?v=xu87YWbr4X0&list=PLu8EoSxDXHP6CGK4YVJhL_VWetA865GOH&index=2).
* **Note:** to open web links in a new window use: _ctrl+click on link_




## :page_facing_up: Table of contents
* [:zap: Javascript Clock](#zap-javascript-clock)
* [:page_facing_up: Table of contents](#page_facing_up-table-of-contents)
* [:books: General info](#books-general-info)
* [:camera: Screenshots](#camera-screenshots)
* [:signal_strength: Technologies](#signal_strength-technologies)
* [:floppy_disk: Setup](#floppy_disk-setup)
* [:computer: Code Examples](#computer-code-examples)
* [:cool: Features](#cool-features)
* [:clipboard: Status & To-Do List](#clipboard-status--to-do-list)
* [:clap: Inspiration](#clap-inspiration)
* [:file_folder: License](#file_folder-license)
* [:envelope: Contact](#envelope-contact)
## :books: General info
* Tutorial Code to create a working clock using just HTML, CSS & javascript.
## :camera: Screenshots
.
## :signal_strength: Technologies
* Ran in Google Chrome browser with: [Javascript engine V8 for Windows (x64)](https://v8.dev/).
## :floppy_disk: Setup
* Open index.html in browser. If any code is changed the browser needs to be refreshed.
## :computer: Code Examples
* function to calculate position of clock hands using new Date().
```javascript
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)`;
}
```
## :cool: Features
* Uses cubic-bezier CSS library for ease-in and ease-out of ticking clock hands.
## :clipboard: Status & To-Do List
* Status: Working
* To-Do: Nothing
## :clap: Inspiration
* [We build a CSS + JS Clock in Vanilla JS — #JavaScript30 2/30](https://www.youtube.com/watch?v=xu87YWbr4X0&list=PLu8EoSxDXHP6CGK4YVJhL_VWetA865GOH&index=2).
## :file_folder: License
* N/A
## :envelope: Contact
* Repo created by [ABateman](https://github.com/AndrewJBateman), email: gomezbateman@yahoo.com