Hi,
New here so hello to all and thanks to have me.
I'm using Thonny 4.1.7 on a Pico W 2040 on Mac.
When it runs:
import time
current_time = time.time()
print(current_time)
local_time = time.localtime(time.time())
print(local_time)
utc_time = time.gmtime(time.time())
print(utc_time)
secs = time.mktime(time.localtime())
print(secs)
All is well:
1755595433
(2025, 8, 19, 9, 23, 53, 1, 231)
(2025, 8, 19, 9, 23, 53, 1, 231)
1755595433
But:
import time
current_time = time.time()
print(current_time)
local_time = time.localtime(time.time())
print(local_time)
utc_time = time.gmtime(time.time())
print(utc_time)
secs = time.mktime(time.localtime())
print(secs)
print(time.ctime())
gives:
1755595636
(2025, 8, 19, 9, 27, 16, 1, 231)
(2025, 8, 19, 9, 27, 16, 1, 231)
1755595636
Traceback (most recent call last):
File "<stdin>", line 11, in <module>
AttributeError: 'module' object has no attribute 'ctime'
And a similar answer with:
formatted_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
AttributeError: 'module' object has no attribute 'strftime'
Or "time.strptime" as well.
I rebooted the Mac and reloaded Thonny to noavail.
Any tips there very welcome!
Renaud F5ZR