Random times of day
This random time generator picks an hour (0–23), a minute (0–59) and optionally a second (0–59), each uniformly at random, and formats the result as a clock time. Every minute of the day has the same chance of appearing, so over many runs the times are evenly spread from midnight to 23:59.
Random time generator formats
24-hour: 07:42 19:05 00:18
24-hour with seconds: 07:42:09 19:05:51
12-hour: 07:42 AM 07:05 PM 12:18 AMIn 12-hour format, midnight is shown as 12:xx AM and noon as 12:xx PM, following the usual convention. The 24-hour format always uses two digits for hours, which makes the values sort correctly as text.
Loading the times into a database or script
The 24-hour output with seconds, such as 14:37:09, is the format SQL TIME columns accept directly, so it is the safest choice for fixtures. 12-hour values need converting on the way in: MySQL reads them with STR_TO_DATE('2:37 PM', '%l:%i %p'), and PostgreSQL accepts '2:37 PM'::time.
For calculations, convert each time to seconds since midnight:
14:37:09 → 14 × 3600 + 37 × 60 + 9 = 52,629 s
00:00:00 → 0 s
23:59:59 → 86,399 s
Durations, averages and "is this within opening hours?" checks become simple integer comparisons. Remember that a span which crosses midnight, such as 22:00 to 02:00, needs 86,400 seconds added to the end time before you subtract.
What random times are useful for
- Test data – fill a
TIMEcolumn, a booking form or an opening-hours widget with varied values. - Edge cases – times around midnight and noon expose bugs in 12/24-hour conversion and in code that assumes a day starts at 1:00.
- Spot checks and reminders – schedule random check-in times so they cannot be anticipated.
- Games and exercises – practice reading clocks, converting between 12- and 24-hour time or calculating durations.
- Load testing – spread simulated events across a day rather than running them all at once.
Options
- How many – up to 10,000 times per run.
- Format – 24-hour or 12-hour with AM/PM.
- Seconds – add a random seconds component for timestamps that need it.
- Sort – put the times in order. In 24-hour format this is chronological order.
12-hour vs 24-hour time
The 24-hour clock is standard in most of the world and in computing (ISO 8601, databases, logs), while the 12-hour clock with AM and PM is common in the United States and a few other countries. Testing both formats catches the classic bugs: 12:30 AM converting to 12:30 instead of 00:30, or 12 PM being treated as midnight.
Limitations
The times are plain clock times with no date or time zone attached, so daylight-saving transitions are not considered. If you need full timestamps, the random date generator can produce date-time and ISO 8601 values in UTC. To add or subtract durations from a time, use the date and time calculator.
All values are generated with a secure random source in your browser and are not stored.