C Example: Unix Timestamp: seconds to UTC date and time
Implements the inverse civil_from_days algorithm to turn serial days since 1970 back into a date, then splits the seconds within a day into hours, minutes and seconds. Converts timestamps 0, 1000000000, 1764000000, 2147483647 and 1700000000 into UTC, covering the epoch and the 2038 boundary.
🖥 Run OnlineGCC 10.2 · C11 standard · click ▶ to run · Copy code
🖨 Reference OutputMatches the online run in a standard C11 environment
0 -> 1970-01-01 00:00:00 UTC 1000000000 -> 2001-09-09 01:46:40 UTC 1764000000 -> 2025-11-24 16:00:00 UTC 2147483647 -> 2038-01-19 03:14:07 UTC 1700000000 -> 2023-11-14 22:13:20 UTC
🧩 Keep Learning