Skip to content
🛠️ToolsShed

Time Unit Converter

Convert between seconds, minutes, hours, days, weeks, months, and years.

About this tool

Time is one of the most fundamental measurements in daily life, yet converting between different time units can be unexpectedly tricky. Whether you're calculating project durations, comparing data from different sources, or simply trying to understand how many seconds are in a week, having a reliable converter at your fingertips saves time and eliminates mental math errors.

Using this time unit converter is straightforward: enter a value in any time unit (seconds, minutes, hours, days, weeks, months, or years) and instantly see the equivalent in all other units. The tool handles both precise conversions and practical approximations—for instance, months and years use standardized calendar values (30 days per month, 365 days per year) to provide consistent results across different date ranges.

This tool is invaluable for project managers tracking timelines, developers calculating timeout values, students solving physics or chemistry problems, and anyone working across international teams where time specifications may differ. Keep in mind that month and year conversions are approximate averages; for exact calendar-based calculations (accounting for varying month lengths or leap years), you may need additional tools.

Frequently Asked Questions

Code Implementation

# Time unit conversion in Python
SECONDS = {
    "ns":  1e-9,       # nanosecond
    "us":  1e-6,       # microsecond
    "ms":  1e-3,       # millisecond
    "s":   1,          # second
    "min": 60,         # minute
    "h":   3600,       # hour
    "d":   86400,      # day
    "wk":  604800,     # week
    "yr":  31536000,   # year (365 days)
}

def convert_time(value: float, from_unit: str, to_unit: str) -> float:
    seconds = value * SECONDS[from_unit]
    return seconds / SECONDS[to_unit]

# divmod approach: seconds → hours, minutes, seconds
def seconds_to_hms(total_seconds: int):
    minutes, secs = divmod(total_seconds, 60)
    hours, mins   = divmod(minutes, 60)
    return hours, mins, secs

# Examples
print(convert_time(1, "h", "min"))    # 60.0
print(convert_time(1, "d", "h"))      # 24.0
print(convert_time(1000, "ms", "s"))  # 1.0
print(seconds_to_hms(3723))           # (1, 2, 3)

Comments & Feedback

Comments are powered by Giscus. Sign in with GitHub to leave a comment.