数据库中是以时间戳的格式保存的时间字段,现在需要显示成日期格式
class User(object):
def created_time(self, obj):
now = int(obj.create_time)
# 转换为其他日期格式,如:"%Y-%m-%d %H:%M:%S"
timeArray = time.localtime(now)
otherStyleTime = time.strftime("%Y-%m-%d %H:%M:%S", timeArray)
return otherStyleTime
list_display = ('created_time')