UTC seconds and time format expression convertion in Python

69 views Asked by At

How to convert a seconds series since 2012-01-01 0:0:0 to a time format expression.

And the inverse? Convert a time expression, such as 2015-6-23 10:00:00, to the seconds since 2012-01-01 0:0:0.

1

There are 1 answers

1
JuanPablo On
import datetime as dt

print (dt.datetime(2015,1,2) - dt.datetime(2015,1,1)).total_seconds()
print dt.datetime(2015,1,1) + dt.timedelta(seconds=3600*24)

the output

http://testedanswers.com/questions/-JsT943k5Y8lTp2dOb3s

Python documentation

https://docs.python.org/2/library/datetime.html