๐Ÿš€ Big upgrades in progress! New tools, faster pages, and more coming soon.

๐Ÿ”ง Arduino Digital clock format Universal Time zone support

Build an Arduino digital clock with universal time zone (UTC) support. Learn how to code customizable time formats and switch time zones easily!

✓ Arduino (.ino) ✓ Live code preview ✓ Free download

๐Ÿ› ๏ธ Technical & Feature Keywords

  • arduino 12 24 hour clock format

  • arduino ds3231 timezone adjustment (assuming you are using an RTC module)

  • arduino ntp server wifi clock (if it fetches time via ESP8266/ESP32)

  • arduino lcd clock format

  • arduino epoch time converter

โš™๏ธ
Customise & Download
Adjust settings below โ€” the code updates live in real time
Live preview
Configure your Digital Clock
200
โ†“ Your settings are reflected in the code below
Generated code โ€” live preview
Arduino (.ino) 0 lines
/*
  ==========================================================
   Digital Clock
   Generated by techlogics.net
   https://techlogics.net/electronics/digital-clock.php
  ==========================================================

   CAUTION: Review this code fully before uploading to any
   hardware. Verify all pin connections and power requirements
   match YOUR specific components. We are not responsible for
   damage to hardware, fire, or injury resulting from incorrect
   wiring, faulty components, or misuse of this code.

   Generated on: 09 Jul 2026
  ==========================================================
*/

/*
  Digital Clock โ€” generated by techlogics.net
  Board: Arduino + DS3231 RTC + 16x2 LCD
*/

#include <Wire.h>
#include <RTClib.h>
#include <LiquidCrystal.h>

RTC_DS3231 rtc;
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

// === User configuration ===
const int   UTC_OFFSET_HOURS   = 5;
const int   UTC_OFFSET_MINUTES = 30;
const bool  USE_24_HOUR_FORMAT = true;
const int   BACKLIGHT_PIN      = 6;
const int   LCD_BRIGHTNESS     = 200;

void boardSpecificSetup() {
  // Default: standard Arduino Uno/Nano pin setup
  pinMode(BACKLIGHT_PIN, OUTPUT);
  analogWrite(BACKLIGHT_PIN, LCD_BRIGHTNESS);
}
void setup() {
  Serial.begin(9600);
  lcd.begin(16, 2);
  boardSpecificSetup();

  if (!rtc.begin()) {
    Serial.println("Could not find RTC");
    while (1);
  }
}

void loop() {
  DateTime now = rtc.now();

  int adjustedHour = now.hour() + UTC_OFFSET_HOURS;
  int adjustedMin  = now.minute() + UTC_OFFSET_MINUTES;
  if (adjustedMin >= 60) { adjustedMin -= 60; adjustedHour += 1; }
  if (adjustedMin < 0)   { adjustedMin += 60; adjustedHour -= 1; }
  if (adjustedHour >= 24) adjustedHour -= 24;
  if (adjustedHour < 0)   adjustedHour += 24;

  lcd.setCursor(0, 0);

  if (USE_24_HOUR_FORMAT) {
    lcd.print(adjustedHour < 10 ? "0" : ""); lcd.print(adjustedHour);
  } else {
    int displayHour = adjustedHour % 12;
    if (displayHour == 0) displayHour = 12;
    lcd.print(displayHour < 10 ? "0" : ""); lcd.print(displayHour);
  }
  lcd.print(":");
  lcd.print(adjustedMin < 10 ? "0" : ""); lcd.print(adjustedMin);

  if (!USE_24_HOUR_FORMAT) {
    lcd.print(adjustedHour >= 12 ? " PM" : " AM");
  }

  delay(1000);
}


/*
  ==========================================================
   End of generated code โ€” techlogics.net
   Found this useful? Visit https://techlogics.net/electronics/digital-clock.php
   for more free CCTV, networking, electronics & finance tools.

   Questions or issues? https://techlogics.net/contact.php
  ==========================================================
*/
How to use

TEST Usage

Recommended products
As an Amazon Associate, techlogics.net may earn from qualifying purchases.