I have a string '201502190759'
. This represents 2015/02/19 at 7:59.
Is there a method within the python library that can convert '201502190759'
into a datetime
object or timestamp?
I have a string '201502190759'
. This represents 2015/02/19 at 7:59.
Is there a method within the python library that can convert '201502190759'
into a datetime
object or timestamp?
Yep, datetime.datetime.strptime
will do it.
>>> import datetime
>>> print(datetime.datetime.strptime('201502190759', '%Y%m%d%H%M'))
2015-02-19 07:59:00
The docs on the format modifiers are here.