python简单的计算过期时间的代码
def time_passed(value): now = datetime.now() past = now - value if past.days: return u'%s天前' % past.days mins = past.seconds / 60 if mins < 60: return u'%s分钟前' % mins hours = mins / 60 return u'%s小时前' % hours
python简单的计算过期时间的代码
def time_passed(value): now = datetime.now() past = now - value if past.days: return u'%s天前' % past.days mins = past.seconds / 60 if mins < 60: return u'%s分钟前' % mins hours = mins / 60 return u'%s小时前' % hours