import time
from datetime import datetime
if __name__ == '__main__':
currenttime = time.time() #epoch time
#print in local datetime
print(datetime.fromtimestamp(currenttime).strftime('%Y-%m-%d %H:%M:%S'))
#print in GMT datetime
print(datetime.utcfromtimestamp(currenttime).strftime('%Y-%m-%d %H:%M:%S'))
# Logic for database insertion...
从你所说的,我认为这应该由数据库(模型)来处理
但是,如果您想获取当前的epoch时间并将其插入数据库,我希望这能有所帮助
相关问题 更多 >
编程相关推荐