0

I have a range of dates and times in such a format, and I have to add seconds to this range. DateTime
0 2021-07-20 23:59:00 1 2021-07-20 23:59:00 2 2021-07-20 23:59:00 3 2021-07-20 23:59:00 4 2021-07-20 23:59:00

357545 2021-07-12 00:00:00 357546 2021-07-12 00:00:00 357547 2021-07-12 00:00:00 357548 2021-07-12 00:00:00 357549 2021-07-12 00:00:00

how it says 23:59:00. I want this to change to the following. DateTime
0 2021-07-20 23:59:00 1 2021-07-20 23:59:58 2 2021-07-20 23:59:56 3 2021-07-20 23:59:54 4 2021-07-20 23:59:52 5 2021-07-20 23:59:50 6 2021-07-20 23:59:48 7 2021-07-20 23:59:46 8 2021-07-20 23:59:44 9 2021-07-20 23:59:42

and so on.

Please help me

Thanks

1 Answers1

0

Since you don't have code in your question it's hard to answer your question directly but I'll give it a shot.

You should be able to add seconds to a datetime string using strftime. Example from https://www.programiz.com/python-programming/datetime/strftime

from datetime import datetime
now = datetime.now() # current date and time
date_time = now.strftime("%m/%d/%Y, %H:%M:%S")  # the %S will add seconds to the output

If you're trying to add seconds to an existing datetime object, you can use timedelta as described by this answer https://stackoverflow.com/a/100345/16338189

import datetime
a = datetime.datetime(100,1,1,11,34,59)
b = a + datetime.timedelta(0,3) # adds 0 days and 3 seconds to 
print(a.time())
print(b.time())
stoddabr
  • 36
  • 3