Custom Clock Time Generator
Generate random clock times with custom hour, minute, and second ranges. Supports 12h/24h formats, sorting, uniqueness, and weighted distribution.
About
Generating random clock times appears trivial until constraints surface. Scheduling algorithms, test-data pipelines, and simulation engines all require times distributed within precise bounds - not merely 00:00 to 23:59. This tool produces n random timestamps bounded by user-defined hour, minute, and second ranges, with optional uniqueness enforcement and weighted distribution across day segments. Output conforms to either ISO 24-hour notation or 12-hour AM/PM convention. The underlying uniform sampling maps Math.random across the integer interval [tmin, tmax] measured in seconds, then decomposes each sample via modular arithmetic. This tool approximates uniform distribution; for cryptographically secure randomness, a dedicated CSPRNG is required.
Practical applications include populating database fixtures with realistic timestamps, generating randomized exam or quiz schedules, stress-testing time-parsing logic, and creating synthetic event logs. When weighted mode is active, the generator biases samples toward user-selected day periods - useful for simulating realistic human activity patterns where events cluster around business hours rather than distributing evenly across midnight-to-midnight. Note: uniqueness is guaranteed only when the requested count does not exceed the total distinct seconds in the configured range.
Formulas
Each random time is produced by sampling a total-seconds value within the configured bounds, then decomposing it into hours, minutes, and seconds via integer division and modulo operations.
For 12-hour conversion:
Where t = total seconds since midnight, tmin and tmax = lower and upper bounds in seconds, h = hours (0 - 23), m = minutes (0 - 59), s = seconds (0 - 59), and rand() returns a uniform value in [0, 1).
Reference Data
| Day Period | Hour Range (24h) | Typical Use Case | Default Weight |
|---|---|---|---|
| Late Night | 00:00 - 05:59 | Batch jobs, cron tasks | 0.05 |
| Early Morning | 06:00 - 07:59 | Alarm clocks, gym schedules | 0.08 |
| Morning | 08:00 - 11:59 | Business meetings, school | 0.22 |
| Midday | 12:00 - 13:59 | Lunch breaks, shift changes | 0.12 |
| Afternoon | 14:00 - 16:59 | Appointments, deliveries | 0.18 |
| Early Evening | 17:00 - 18:59 | Commute, restaurant bookings | 0.13 |
| Evening | 19:00 - 20:59 | Events, entertainment | 0.10 |
| Night | 21:00 - 23:59 | Night shifts, security logs | 0.07 |
| Common Time Formats | |||
| ISO 8601 | 14:30:00 | HH:MM:SS | |
| 12-Hour | 2:30:00 PM | h:MM:SS AM/PM | |
| Short 24h | 14:30 | HH:MM | |
| Short 12h | 2:30 PM | h:MM AM/PM | |
| Seconds Only | 52200 | Total seconds since midnight | |
| Military | 1430 | HHMM no colon | |
| Maximum Unique Values by Precision | |||
| Hours only | 24 distinct values | Full day | |
| HH:MM | 1,440 distinct values | 24 × 60 | |
| HH:MM:SS | 86,400 distinct values | 24 × 3600 | |