Thursday, 23 September 2021

Python: Get today date and time

‘datetime.now()’ or ‘datetime.today()’ methods return the today date and time.

 

today_details_1.py

from datetime import datetime

print(datetime.now())
print(datetime.today())

 

Output

2021-09-18 19:01:01.334496
2021-09-18 19:01:01.334542

 

   

Previous                                                    Next                                                    Home

No comments:

Post a Comment