Converting ISO 8601 date time to seconds in Python -


i trying add 2 times together. iso 8601 time stamp '1984-06-02t19:05:00.000z', , convert seconds. tried using python module iso8601, parser.

any suggestions?

if want seconds since epoch, can use python-dateutil convert datetime object , convert seconds using strftime method. so:

>>> import dateutil.parser dp >>> t = '1984-06-02t19:05:00.000z' >>> parsed_t = dp.parse(t) >>> t_in_seconds = parsed_t.strftime('%s') >>> t_in_seconds '455047500' 

so halfway there :)


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -