Skip to main content
1 de 2

Capturar range de tempo em UNIX

Estou tentando capturar em formato de data UNIX o range de tempo de 1 dia

SCRIPT

#!/usr/bin/python
# -*- coding: utf-8 -*-
import time
import datetime
from datetime import datetime

now = datetime.now()

dateNow = '' + str(now.day - 1) + '/' + str(now.month) + '/' \
    + str(now.year) + ''

start = '' + dateNow + ' 00:00'
end = '' + dateNow + ' 23:59'

print(start)

startTimestamp = int(time.mktime(datetime.datetime.strptime(start,
                     '%d/%m/%Y %H:%M').timetuple()))

endTimestamp = int(time.mktime(datetime.datetime.strptime(end,
                   '%d/%m/%Y %H:%M').timetuple()))

print(startTimestamp)

OUTPUT

28/10/2019 00:00
Traceback (most recent call last):
  File "main.py", line 17, in <module>    startTimestamp = int(time.mktime(datetime.datetime.strptime(start,AttributeError: type object 'datetime.datetime' has no attribute 'datetime'