now = datetime.strptime(str(col[4].text), '%d.%m.%Y, %H:%M:%S')
print(type(now))
But the output says that the type of the now variable is: class 'datetime.datetime'
Guys i dont know how to covnert it i propriet fromat, can anyone help?
now = datetime.strptime(str(col[4].text), '%d.%m.%Y, %H:%M:%S')
print(type(now))
But the output says that the type of the now variable is: class 'datetime.datetime'
Guys i dont know how to covnert it i propriet fromat, can anyone help?
Datetime objects have a default format when they are printed. The format section of strptime defineds the string format that the datetime STARTS as. Once it is converted to a datetime, it uses the standard representation defined by __repr__ and __str__.
To convert these values to strings in the format that you want, you can use strftime:
now = datetime.strptime(str(col[4].text), '%d.%m.%Y, %H:%M:%S')
now = now.strftime('%d.%m.%Y, %H:%M:%S')
The docs for datetime objects states that print(datetime_object) will return the ISO format representation of datetime_object. ISO format is the YYYY-MM-DD format that you are seeing when printing the datetime.
Read more here: https://docs.python.org/3.2/library/datetime.html