Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

time.Now().Unix() returns same unix time on every run #104

Closed
aman00323 opened this issue Mar 2, 2022 · 1 comment
Closed

time.Now().Unix() returns same unix time on every run #104

aman00323 opened this issue Mar 2, 2022 · 1 comment

Comments

@aman00323
Copy link

  • I have been trying to use time. Now().Unix() but on every run, it returns the same timestamp.

  • Do we have to explicitly specify the timezone to be followed?

  • Here is below example that I was expecting to run

https://goplay.tools/snippet/9E6tmxLJs2u

@x1unix
Copy link
Owner

x1unix commented Mar 2, 2022

@aman00323 This is related to how official Go playground - works. See Stack Overflow article

In the playground the time begins at 2009-11-10 23:00:00 UTC (determining the significance of this date is an exercise for the reader). This makes it easier to cache programs by giving them deterministic output.

If you want to use actual time and date - use WebAssembly backend which will run Go code in your browser:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants