You can format a date in Python using the strftime
function of the datetime
module. Here's an example of how to format today's date in the format you requested:
main.py133 chars7 lines
This will output: October 11, 2021 09:56:26.135382 AM
Alternatively, if you have a date as a string in a different format, you can use datetime.strptime
to parse it into a datetime
object, and then use strftime
to format it:
main.py181 chars8 lines
This will output: October 13, 2014 11:13:00.000000 AM
gistlibby LogSnag