Skip to content

Instantly share code, notes, and snippets.

@Akuba-
Akuba- / sectostr.py
Last active July 27, 2016 08:46
convertes a unix timestamp into a human readable string in python (ex: 2 years, 1 month and 7 seconds)
import time
def sectostr(t):
_time = ""
(t, _time) = sectostr_one(31536000, "year", "years", "one", t, _time)
(t, _time) = sectostr_one(604800, "week", "weeks", "one", t, _time)
(t, _time) = sectostr_one(86400, "day", "days", "one", t, _time)
(t, _time) = sectostr_one(3600, "hour", "hours", "one", t, _time)
(t, _time) = sectostr_one(60, "minute", "minutes", "one", t, _time)
(t, _time) = sectostr_one(1, "second", "seconds", "one", t, _time)