# Convert seconds to hh:mm:ss format

Format a whole number of seconds as zero-padded hours, minutes and seconds.

Canonical: https://1loc.dev/date-time/convert-seconds-to-hh-mm-ss-format/
Version: 1.0.0
Runtime: JavaScript · Node.js 22 / modern browsers
Verification: Local fixtures; no external services
Updated: 2026-10-28

## Implementation

```javascript
function formatSeconds(seconds) { return [Math.floor(seconds / 3600), Math.floor(seconds % 3600 / 60), seconds % 60].map(part => String(part).padStart(2, '0')).join(':'); }
```

## Input

```json
3725
```

## Expected output

```json
"01:02:05"
```

## Edge case

Input:
```json
90061
```
Output:
```json
"25:01:01"
```

## Limits

- Hours keep counting past 24. The original toISOString version wrapped around after one day.
- Input is a non-negative integer number of seconds.

The lab validates types and size before calling this function. Add equivalent validation at your own trust boundary.

## Source and license

Original: https://github.com/phuocng/1loc/blob/14b481cf60dff1620ab1bb99a43b1f68068cdd9b/contents/convert-seconds-to-hh-mm-ss-format.mdx
Source file (this edition): https://github.com/akamind/1loc/blob/0a77f131b22d2ba3b7ec1728846f900c22821678/contents/convert-seconds-to-hh-mm-ss-format.mdx
Author: Nguyen Huu Phuoc and original contributors
Contributors: See original repository history
Source commit: 14b481cf60dff1620ab1bb99a43b1f68068cdd9b
Copyright (c) 2020 phuoc-ng
License: MIT — https://1loc.dev/licenses/
Maintainer: Oveyon
Modifications: Replaced the toISOString variant, which wrapped after 24 hours, with zero-padded arithmetic that keeps counting hours. Original MDX retained as inert source evidence.
