1

I am trying to get AM or PM at the last of time I get using time.ctime() but I can't find any possible solution. Here is an example:

>>> import time
>>> time.ctime()
'Thu Sep 13 8:35:24 2018'

It is giving me Thu Sep 13 8:35:24 2018 but I want the output to be like: Thu Sep 13 8:35:24 AM 2018

How can I achieve this?

Nouman
  • 6,947
  • 7
  • 32
  • 60

1 Answers1

5

I read the documentation carefully and finally build that piece of code by myself:

time.strftime("%a %b %d %I:%M:%S %p %Y")
Nouman
  • 6,947
  • 7
  • 32
  • 60