To translate the date and time "05-06-2016 00:00:00" into a specific format in Python, you can use the strptime()
and strftime()
functions from the datetime
module.
Here's an example code that demonstrates the conversion:
main.py352 chars13 lines
In the code above, the strptime()
function is used to convert the input datetime string into a datetime
object with the specified format ("%d-%m-%Y %H:%M:%S"). Then, the strftime()
function is used to format the datetime
object into the desired format ("%Y-%m-%d %H:%M:%S").
The output of the code will be: "2016-06-05 00:00:00", which is the input datetime string formatted as "YYYY-MM-DD HH:MM:SS".
gistlibby LogSnag