Skip to content

setting local time on pico w #9545

Oct 7, 2022 · 9 comments · 13 replies
Discussion options

You must be logged in to vote

I think it makes sense for ntptime to set the time in UTC. The issue is that micropython itself has no built-in notion of timezones or the current timezone, so time.localtime and time.gmtime will always return the same thing.

In micropython-lib we have a (micro) datetime package. I have not looked into it in detail, but I believe that as long as your app code knows the current timezone, then you can construct offset times. e.g. assuming the clock has been set by ntptime

my_timezone = timezone(timedelta(hours=10))
current_time = datetime.datetime.now(my_timezone)

https://github.com/micropython/micropython-lib/tree/master/python-stdlib/datetime

(You can install this via mip if you're using …

Replies: 9 comments 13 replies

Comment options

You must be logged in to vote
3 replies
@diegorebollo
Comment options

@jimmo
Comment options

jimmo Oct 7, 2022
Maintainer

@profhuster
Comment options

Answer selected by jimmo
Comment options

You must be logged in to vote
1 reply
@clach04
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
6 replies
@Zorbadil
Comment options

@GM-Script-Writer-62850
Comment options

@peterhinch
Comment options

@vodkawasserfall
Comment options

@peterhinch
Comment options

Comment options

You must be logged in to vote
3 replies
@peterhinch
Comment options

@clach04
Comment options

@peterhinch
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment