1

I am trying to get the current time in millisecond using Go language https://golang.org/#

package main
import "fmt"
import "time"
func main() {

    now := time.Now()
    secs := now.Unix()
    nanos := now.UnixNano()
    fmt.Println(now)

    millis := nanos / 1000000
    fmt.Println(millis)

}

When I run the above code using the mentioned website the output I get is following:

2009-11-10 23:00:00 +0000 UTC
1257894000000

I am not able to understand why I am not getting current date as result? I tried the same code on another website https://www.epochconverter.com/ and got the correct result which is following :

Time Now is : 
1496230018

Can someone confirm if the problem is related to my code or is the website that's showing the wrong result?

Thanks

Steven Doggart
  • 43,358
  • 8
  • 68
  • 105
Anshul
  • 7,914
  • 12
  • 42
  • 65

1 Answers1

10

It seems like you're running this on the Go playground (play.golang.org). The time is fixed on the Go playground, try running it locally instead.

Machiel
  • 1,495
  • 12
  • 15