Random Time Generator
Generate random times (HH:MM:SS) within a window.
Random time-of-day generator explained
A random time-of-day generator picks a clock time uniformly within a configurable window (defaulting to 08:00–18:00). It is useful for fixture data (appointment_time, scheduled_at, opening_hours), seeding calendar mock-ups, fuzzing parsers, and generating realistic event logs. Unlike a Unix timestamp, this generator emits only the time component — no date attached.
12-hour vs 24-hour clock
The world is split between two notations:
- 24-hour (ISO 8601, military, most of Europe, Brazil, Portugal):
00:00to23:59. Unambiguous, sortable as a string, the only sane choice for storage. - 12-hour (US, UK, Australia colloquial):
1:00 AMthrough12:59 PM, repeating. Beware the midnight/noon trap:12:00 AMis midnight and12:00 PMis noon — counterintuitive enough that style guides recommend "12 noon" / "12 midnight". - Military time: identical to 24-hour but written without a colon —
1430instead of14:30, pronounced "fourteen hundred hours".
ISO 8601 time representations
The ISO 8601 standard allows several variants for clock time:
HH:MM → 14:30 (minute precision)
HH:MM:SS → 14:30:45 (second precision)
HH:MM:SS.sss → 14:30:45.123 (millisecond)
HH:MM:SS±HH:MM → 14:30:45-03:00 (with UTC offset)
HH:MM:SSZ → 14:30:45Z (UTC, the "Zulu" suffix)
Some legacy SQL stacks accept HHMMSS without separators; avoid it for new work — it confuses humans and date pickers alike.
Time zones and odd offsets
There are 24 nominal time zones, but the real list has many fractional offsets. India uses +05:30, Newfoundland uses -03:30 and Nepal sits on +05:45. A bare time string like 14:30 is ambiguous without a date and a zone — that is why ISO 8601 recommends carrying an offset when the value crosses systems.
Daylight Saving Time introduces a deeper ambiguity: on the day the clock falls back, the local time between 01:00 and 02:00 occurs twice. Brazil abolished DST in 2019 (Decreto 9.772/2019), so for new Brazilian data the ambiguity is gone — but historical timestamps before 2019 still need careful handling.
Uniform sampling and edge cases
The algorithm is straightforward: convert the lower and upper bounds to seconds-since-midnight, draw a uniform random integer in that range and convert back:
lo = h1*3600 + m1*60
hi = h2*3600 + m2*60
sec = randInt(lo, hi)
out = `${(sec/3600|0).pad(2)}:${((sec/60|0)%60).pad(2)}:${(sec%60).pad(2)}`
One subtle pitfall: an "overnight" range such as 22:00 → 04:00 wraps past midnight, and naïve subtraction yields a negative window. Handle it by adding 24h to the upper bound and taking the result modulo 24h.
FAQ
Can I restrict to business hours only? Yes — set De and Até to your business window (defaults already cover 08:00–18:00).
Does the output include a time zone? No — the generator emits bare HH:MM values. If you need a zone, append it in your own pipeline (e.g. 14:30 America/Sao_Paulo).
Can I get times overnight (22:00 to 04:00)? Most random-time tools assume a same-day window. For overnight, generate two batches (22:00–23:59 and 00:00–04:00) and concatenate.
What is this useful for? Seeding mock created_at, scheduled_at and appointment_time fields, generating random shift schedules for testing scheduling algorithms, simulating arrival times for queueing simulations, and stress-testing time-parsing libraries with realistic input.
Related Tools
Random String Generator
Generate customizable random strings — set the alphabet (A-Z, a-z, 0-9, hex, base32, base58, symbols), length and quantity. Useful for tokens, IDs and fixtures. Everything in your browser.
Random Emoji Generator
Generate a sequence of random emojis — pick theme (general, food, animals, sports) and quantity. For design, mockups and messages.
Random Timestamp Generator
Generate random Unix timestamps within a date range. Useful for test data.
Random Date Generator
Generate random dates within a defined range — useful for seeding test databases, app fixtures or mock spreadsheets.
Random Color Generator
Generate random colors in HEX, RGB and HSL with one click. Great for design inspiration, palettes, UI testing and beating creative block.
Random Words Generator
Generate random words in Portuguese or English. Useful for brainstorming, games, UI tests and identifier generation.