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