Skip to main content
removeu 17 caracteres do conteúdo; tags editadas
Fonte Link
hkotsubo
  • 66,9mil
  • 25
  • 87
  • 170

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 Saída:

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'

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'

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

#!/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)

Saída:

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'
Fonte Link

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'