0

I need to increase the current time by one minute and my code looks very complicated. I would be glad to know if there is any simple way for this.

My code is:

import time
a = (time.strftime("%I:%M %p")).lower()
if a[0]=='0':
    #time = a.replace(a[0],"")
    time = a[1:]
    #print (time)
    if time[3]=='9':
        time = list(time)
        time[3] = 0
        time[3] = str(time[3])
        time[2] = (int(time[2])+1)
        time[2] = str(time[2])
        times = ''.join(time)
        time = times
        print (time)
    else:   
        time = list(time)
        time[3] = (int(time[3])+1)
        time[3] = str(time[3])
        times = ''.join(time)
        time = times
        print ((time))

else:
    time = a
    print (time)
    print (time[4]+"1")

On the whole if the time is 3:49 pm it should return me 3:50 pm and if it's closing to an hour i.e if it is 3:59 pm it should be 4:00 pm

Please let me know if there's any simple way for this. Thanks in advance.

Nitesh Ash
  • 193
  • 1
  • 1
  • 5

0 Answers0