Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Go time.Now() is always 2009-11-10 23:00:00 +0000 UTC

Tags:

datetime

time

go

I'm running Go version 1.3 on Windows 7x64. After I run the following code I always get 2009-11-10 23:00:00 +0000 UTC.

package main  import (     "fmt"     "time" )  func main() {     fmt.Println(time.Now()) } 

I know that Go Playgroud has this fixed time for a reason, but I don't understand why I get this date in my box.

UPDATE: I solved this issue by upgrading the Go version from 1.2.2 to 1.3.

Trying to reproduce the issue, I realized this had been fixed after switching the computer off and on the next day.

I recommend to restart the computer after upgrading to 1.3.

like image 982
edcaceres Avatar asked Jul 02 '14 19:07

edcaceres


People also ask

What is the time on Go playground?

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. There are also limits on execution time and on CPU and memory usage.

What is the type of time now () in Golang?

The Now() function in Go language is used to find the current local time. Moreover, this function is defined under the time package. Here, you need to import the “time” package in order to use these functions. Return Value: It returns the current local time.


1 Answers

This is the time and date of Go Lang's birthday.

They use this as the fixed time in the Go Tour, so perhaps you are running the tour.

like image 117
tomglynch Avatar answered Oct 05 '22 16:10

tomglynch