TextClock displayed server time and date. Today, JavaScript handles time display client-side with timezone awareness and real-time updates.
Date & Time
Fast 2KB alternative to Moment.js. Same modern API, immutable, chainable. Plugins for timezones, relative time, and formatting.
Modern JavaScript date utility library. Over 200 functions, modular design, TypeScript support. Tree-shakable for minimal bundle size.
Modern date-time library by Moment.js team. Built-in timezone support using Intl API, immutable, good documentation.
Modern browsers have powerful built-in date formatting with Intl.DateTimeFormat. No library needed for basic use cases.
Free embeddable world clocks and countdown timers. Multiple styles, customizable colors, any timezone supported.
Simple JSON API for current time in any timezone. No authentication required, free for non-commercial use.
function updateClock() {
const now = new Date();
const options = {
weekday: 'long',
year: 'numeric',
month: 'long',
day: 'numeric',
hour: '2-digit',
minute: '2-digit',
second: '2-digit'
};
document.getElementById('clock').textContent =
now.toLocaleDateString('en-US', options);
}
setInterval(updateClock, 1000);
updateClock();
import dayjs from 'dayjs';
// Format: Monday, December 16, 2024 3:45 PM
const formatted = dayjs().format('dddd, MMMM D, YYYY h:mm A');
// Relative time: "2 hours ago"
import relativeTime from 'dayjs/plugin/relativeTime';
dayjs.extend(relativeTime);
const relative = dayjs('2024-12-16').fromNow();
| Feature | TextClock (CGI) | JavaScript |
|---|---|---|
| Time source | Server | Client (local) |
| Real-time update | No | Yes |
| User's timezone | No | Automatic |
| Custom formats | Limited | Extensive |
| Relative time | No | "2 hours ago" |
| Multiple timezones | Complex | Easy |
| Server load | Each request | None |
Minimal: Native Intl.DateTimeFormat
Lightweight: Day.js (~2KB)
Full-featured: date-fns
Timezone heavy: Luxon
npm install dayjs
npm install date-fns
npm install luxon