我有以下代码从数据库中提取postgres CURRENT_TIMESTAMP
cursor.execute("SELECT submitdate FROM journeys WHERE display = true")
submitDate = cursor.fetchone()['submitdate']
返回
2015-08-11 12:44:31.790462
我如何将其格式化为例如11-08-2015
?
我已经读过并试过这样的事情,但他们没有工作
print(
datetime.datetime.fromtimestamp(
int("1284101485")
).strftime('%Y-%m-%d %H:%M:%S')
)
答案 0 :(得分:0)
有效的解决方案来自Abhis上面的评论。
submitDate.strftime("%d-%m-%Y")