I have code in Python Pandas like below:
print("Date: ", datetime.now().strftime("%d-%m-%Y %I:%M:%S"))
And it generates result: Date: 14-09-2021 08:36:23
Nevertheless, I would like to have something like Date: 14-09-2021 20:36:23
.
So at AM I would like to have time like 08:22:13
and so on and at PM I prefer to have format of time like: 20:22:13
.
How can I modify my code above to achieve result as I need ?
CodePudding user response:
%I indicates 12 hour format. I believe to solve your issue you have to switch %I to %H (24 hour format).