How to print the current time in the format Day, Date Month Year HH:MM:SS?
10,811
datetime module does all the job
>>> import datetime
>>> datetime.datetime.now().strftime("%a, %d %B %Y %H:%M:%S")
'Tue, 29 August 2017 03:04:21'
Author by
Diesel Kumar
Updated on June 05, 2022Comments
-
Diesel Kumar almost 2 years
How to print the current time in the format
Day, Date Month Year HH:MM:SS
Mon, 28 Aug 2017 15:37:01 .
And then, convert this timestamp to epoch seconds & vice-versa.
-
AChampion over 6 yearsHave you explored the
datetime
module? -
Pavan Chandaka over 6 yearsdocs.python.org/2/library/datetime.html. Please walk through this and help yourself
-
-
Marki555 almost 6 years
%I
is time in 12hour AM/PM format. To get hours in 24h format, use%H
. -
Vijay Kumar almost 6 yearshow do you get the same but in UTC, this one is printing local time
-
Panagiotis Simakis almost 6 years@VijayKumar
datetime.datetime.utcnow().strftime("%a, %d %B %Y %H:%M:%S")
for UTC