time range like this
strart_date_time = datetime(2021, 1, 1, 5, 00, 00)
end_date_time = datetime(2021,1, 3, 00,00,00)
I want Output Like This I mean I want every single second count between given time range hope you understand..... ThankYou in advance
output-
2021, 1, 1, 0, 00, 01
2021, 1, 1, 0, 01, 02
2021, 1, 1, 2, 30, 03
...
CodePudding user response:
You can get the time difference in seconds, loop and display new date at each second
from datetime import datetime, timedelta
start_date_time = datetime(2021, 1, 1, 5, 00, 00)
end_date_time = datetime(2021,1, 3, 00,00,00)
time_diff = int((end_date_time - start_date_time).total_seconds())
for i in range(time_diff):
print(start_date_time timedelta(0, i))