Staaarter

Truncate a Clock Time

Truncates a 24-hour clock time (HH:MM:SS) to a chosen precision, hour or minute, zeroing out everything finer instead of rounding it. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-08-05
By Staaarter Team
clocktruncation

Overview

Introduction

Sometimes you don't want the nearest hour or minute for a timestamp, you want exactly what came before it, with everything finer simply dropped.

This tool truncates a 24-hour clock time down to the hour or the minute, without any rounding, so the result is always earlier than or equal to the original time.

What Is Truncate a Clock Time?

A clock time truncator: give it a 24-hour HH:MM:SS time and a precision, hour or minute, and it zeroes out everything finer than that precision.

Unlike rounding, truncation never moves the result forward past the original time; it only ever strips detail off the end.

How Truncate a Clock Time Works

The input time is validated and split into hours, minutes, and seconds.

Seconds are always set to zero. If the chosen precision is "hour", minutes are also set to zero; if it's "minute", the original minutes value is kept as-is.

When To Use Truncate a Clock Time

Use it when grouping events by hour or by minute and you need a consistent, non-rounded bucket key, like "which hour did this happen in."

It's also useful for stripping seconds from a display timestamp when second-level precision isn't meaningful to show.

Features

Advantages

  • Predictable, non-rounding behavior: the truncated result is always the original time with trailing detail zeroed, never adjusted forward.
  • Simple two-option precision, hour or minute, with no ambiguity about which way values move.
  • Useful as a stable bucketing key for grouping timestamps.

Limitations

  • Only supports hour and minute precision; there's no option to truncate to the nearest 10 minutes or similar sub-hour bucket, that's Clock Time Rounder's role instead.
  • Operates on a bare clock time only, with no date component to truncate alongside it.

Examples

Truncating to the minute

Input

14:05:09
minute

Output

14:05:00

Seconds are dropped to 00 while the hour and minute stay exactly as entered.

Truncating to the hour

Input

14:05:09
hour

Output

14:00:00

Both minutes and seconds are zeroed, leaving only the hour.

Best Practices & Notes

Best Practices

  • Use hour-precision truncation as a grouping key when bucketing large volumes of timestamps by the hour they occurred in.
  • Reach for Clock Time Rounder instead if you actually want the closest hour or minute rather than a strict floor.

Developer Notes

The transform is a straightforward conditional: `const minutes = precision === "hour" ? 0 : time.minutes; const seconds = 0;`, then the three parts are re-joined with `pad2`. No arithmetic beyond field selection is needed since truncation never carries values between fields.

Truncate a Clock Time Use Cases

  • Bucketing log timestamps by the hour they occurred in for aggregation
  • Stripping seconds from a display timestamp when only minute-level precision matters
  • Normalizing timestamps to a coarser grain before deduplicating near-identical entries

Common Mistakes

  • Expecting truncation to round to the nearest hour or minute; it always floors toward the earlier value instead.
  • Passing a precision value other than "hour" or "minute", like "second", which is rejected since there's nothing finer than seconds to truncate to.

Tips

  • Combine hour-precision truncation with a grouping or counting step elsewhere in your workflow to build an hourly histogram of timestamps.
  • If you need rounding instead of a hard floor, use Clock Time Rounder with a 60-minute interval for the same hour-level grouping but rounded behavior.

References

Frequently Asked Questions