Skip to content

Update time #258

Apr 12, 2024 · 1 comments · 10 replies
Discussion options

You must be logged in to vote

When you say “cronjob”, do you mean a program running on gokrazy?

The gokrazy packer copies /etc/localtime from the host to the instance, so as long as you create the instance on a computer with the desired time zone configured, the default time zone on the gokrazy instance should match what you want.

That said, you can always make your Go programs work in any environment (regardless of its default timezone) and use the desired time zone explicitly. For example, to schedule tasks in Zürich time, I use:

        loc, err := time.LoadLocation("Europe/Zurich")
        if err != nil {
                panic(err)
        }

And then, when I need the current time, I use time.Now().In(loc)

Replies: 1 comment 10 replies

Comment options

You must be logged in to vote
10 replies
@BrunoTeixeira1996
Comment options

@stapelberg
Comment options

@BrunoTeixeira1996
Comment options

@stapelberg
Comment options

@BrunoTeixeira1996
Comment options

Answer selected by BrunoTeixeira1996
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants