Format a Duration as Human-Readable Time
Asked at Netflix · Coding Questions · Difficulty: Easy · Last asked Jan 25, 2026
Write a function that converts a duration given in seconds into a human-readable string. Break it into years, days, hours, minutes, and seconds. Hide any unit whose value is zero, but always show seconds (even if 0). Do not use any date/time libraries.
Loading the problem…