Parse time

Normalize constrained 12-hour or 24-hour clock text and calculate seconds since midnight.

freeworks offlinenothing uploaded
ToolTime Parser
Input
Output
Put this on your own site

The frame below runs the same code as this page, in the reader's own browser. Nothing is sent to us, and nothing is sent to you.

Pick a dark background and the text and panels follow it, so the frame stays readable on a dark page.

Preview

How it works

Anchored patterns accept H:MM[:SS] with AM/PM or without a suffix, validate each component, and apply the noon and midnight conversions. Omitted seconds become 00 and suffix-free input always means 24-hour time.

  • No locale guess turns an unsuffixed 3:45 into an afternoon value.
  • Both outputs include seconds so their precision is explicit.

Worked example

Parse 12-Hour Time
Parse a 12-hour time string into its components
Input
											3:45 PM
										
Output
												24-hour: 15:45:00
12-hour: 3:45:00 PM
Total seconds since midnight: 56700
											

When to use this

Scheduling forms normalize AM/PM input, fixtures calculate seconds since midnight, and data cleanup standardizes clock labels.

Edge cases

  • 12:00 AM becomes 00:00:00, while 12:00 PM remains 12:00:00.
  • 3:45 without AM or PM means 03:45.
  • 24:00 and :60 leap seconds are outside the accepted 00:00:00–23:59:59 range.

References