python get the current date and time 28datetime 29

Solutions on MaxInterview for python get the current date and time 28datetime 29 by the best coders in the world

showing results for - "python get the current date and time 28datetime 29"
Ariadna
24 Aug 2017
1from datetime import datetime
2
3# datetime object containing current date and time
4now = datetime.now()
5 
6print("now =", now)
7
8# dd/mm/YY H:M:S
9dt_string = now.strftime("%d/%m/%Y %H:%M:%S")
10print("date and time =", dt_string)	
11
12# now = 2021-06-25 07:58:56.550604
13# date and time = 25/06/2021 07:58:56