View original Gist on GitHub
published = '1466625902' then = datetime.fromtimestamp(int(published)) now = datetime.now() elapsed = now - then minutes = floor(elapsed.seconds / 60) hours = floor(minutes / 60) return '{} days and {} hours ago'.format(elapsed.days, hours)