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'
Share:
10,811
Diesel Kumar
Author by

Diesel Kumar

Updated on June 05, 2022

Comments

  • Diesel Kumar
    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.

  • Marki555
    Marki555 almost 6 years
    %I is time in 12hour AM/PM format. To get hours in 24h format, use %H.
  • Vijay Kumar
    Vijay Kumar almost 6 years
    how do you get the same but in UTC, this one is printing local time
  • Panagiotis Simakis
    Panagiotis Simakis almost 6 years
    @VijayKumar datetime.datetime.utcnow().strftime("%a, %d %B %Y %H:%M:%S") for UTC