Reputation: 702
I have the following code that extracts a postgres CURRENT_TIMESTAMP from a database
cursor.execute("SELECT submitdate FROM journeys WHERE display = true")
submitDate = cursor.fetchone()['submitdate']
which returns
2015-08-11 12:44:31.790462
How would I format this to show as 11-08-2015
for example?
I've read about and tried things such as this but they don't work
print(
datetime.datetime.fromtimestamp(
int("1284101485")
).strftime('%Y-%m-%d %H:%M:%S')
)
Upvotes: 3
Views: 12177
Reputation: 702
The solution that worked comes from Abhis's comment above.
submitDate.strftime("%d-%m-%Y")
Upvotes: 2