8000 GitHub - utsavpatel562/CSS-JavaScript: Nixie Tube Clock
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

utsavpatel562/CSS-JavaScript

Repository files navigation

JavaScript Digital Clock

Welcome to the JavaScript Digital Clock repository! This project implements a digital clock that displays the current time and date in a 12-hour format with AM/PM indication, as well as the current date in MM/DD/YY format. The clock automatically updates every minute to keep the time accurate.

Table of Contents

Features

  • Displays current time in a 12-hour format with AM/PM indication.
  • Automatically updates every minute.
  • Shows the current date in MM/DD/YY format.
  • Easy-to-read and customizable layout.

Getting Started

To run the clock on your local system, follow these steps:
1. Clone this repository:
git clone 2. Open the index.html file in a web browser to view the clock.

Usage

Once you open the clock in a web browser, it will display the current time and date. The clock updates every minute, ensuring that the displayed time is accurate.

Customization

You can customize the appearance of the clock by modifying the accompanying CSS and HTML files. This can include changing fonts, colors, and layout to match your preferences.

Changing Time Display

To modify the way time is displayed, you can adjust the following JavaScript function:
function updateTimeAndDate() { const now = new Date(); let hours = now.getHours(); const minutes = now.getMinutes().toString().padStart(2, '0'); let amPm = hours >= 12 ? 'PM' : 'AM'; if (hours > 12) { hours -= 12; } else if (hours === 0) { hours = 12; } let timeStr = hours.toString().padStart(2, '0') + minutes; if (timeStr.startsWith('0')) { timeStr = ' ' + timeStr.slice(1); } let month = (now.getMonth() + 1).toString().padStart(2, '0'); let day = now.getDate().toString().padStart(2, '0'); const year = now.getFullYear().toString().slice(-2); if (month.startsWith('0')) { month = ' ' + month.slice(1); } if (day.startsWith('0')) { day = ' ' + day.slice(1); } const displayStr = timeStr + amPm + month + day + year; for (let i = 0; i < 12; i++) { document.getElementById('char' + i + '1').textContent = displayStr[i]; document.getElementById('char' + i + '2').textContent = displayStr[i]; } }

Contributing

Contributions are welcome! If you'd like to contribute, please fork the repository and submit a pull request. Make sure to follow the existing code style and write clear, concise commit messages.

License

This project is licensed under the MIT License - see the LICENSE file for details.

0