(python2.7.13)
In [1]: from datetime import datetime In [2]: now = datetime.now() In [3]: now Out[3]: datetime.datetime(2017, 12, 12, 15, 42, 57, 966893) In [4]: int(now.strftime('%s')) Out[4]: 1513060977 In [5]: datetime.fromtimestamp(1513060977) Out[5]: datetime.datetime(2017, 12, 12, 15, 42, 57)
>>> from datetime import datetime >>> datetime.now().strftime('%s') '1616570537'