How do I do this ?
Code: Select all
def local_dt():
try:
r = rtc.now() #r= (2021, 7, 25, 10, 58, 46, 25361, None)
year = r[0]
year= str(year)
month= r[1]
month=str(month).zfill(2)
day= r[2]
day=str(day).zfill(2)
min =r[4]
min = str(min).zfill(2)
hour = r[3]
hour = str(hour).zfill(2)
sec = r[5]
sec = str(sec).zfill(2)
local_dt = day +'/'+ month +'/'+ year + ' '+ hour +':'+ min +'.'+ sec
return local_dt
except Exception as e:
print('## local_dt failed',e)
## local_dt failed 'str' object has no attribute 'zfill'
Traceback (most recent call last):