\ Convert Unix timestamp to Date and format as 'YYYY-MM-DD HH:MM:SS' : unix-to-date ( unix-timestamp -- year month day hour minute second ) dup 60 /mod \ seconds swap dup 60 /mod \ minutes swap dup 24 /mod \ hours swap dup 86400 / \ days since epoch 1970 + \ simplistic year calculation (not accounting for leap years) \ Format output as 'YYYY-MM-DD HH:MM:SS' swap >r swap >r swap >r r@ . 4 spaces r> 0 . r> 0 . r> 0 . r> ." " . r> 0 . r> 0 . r> 0 . ; \ Example usage 299429912 unix-to-date
unix-to-date
mod
60 /mod
12345 60 /mod
86400 *
5 86400 *
365 * 86400 *
1 365 * 86400 *
swap
5 10 swap
dup
5 dup
125 60 mod
+
5 3 +
-
10 5 -