0

What is the quickest/most straight forward way to print the current date & time in python?

29th Jun 2020, 9:33 PM
Nathan Trapero
Nathan Trapero - avatar
3 Respuestas
+ 10
This is the most straightforward way I know: from datetime import datetime now = datetime.now() print(now)
29th Jun 2020, 9:39 PM
🌱Zuhal🐛🌿
🌱Zuhal🐛🌿 - avatar
+ 5
Using datetime.now() shows the date but also the time: >>> print(datetime.now()) 2020-06-30 13:20:42.540223 if you only need to have the date, you better use this: from datetime import date print(date.today()) result will be: 2020-06-30
30th Jun 2020, 11:22 AM
Lothar
Lothar - avatar