Nouman
Nouman

Reputation: 7313

Get AM or PM using 'time'

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?

Upvotes: 1

Views: 955

Answers (1)

Nouman
Nouman

Reputation: 7313

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

time.strftime("%a %b %d %I:%M:%S %p %Y")

Upvotes: 5

Related Questions