necroface necroface - 3 years ago 213
Javascript Question equivalent in Go

In JavaScript, I can assign:

var now =;

Then use
to calculate as a number variable

type in Go doesn't seem to meet this demand. What is the Go equivalent of JavaScript's

Answer Source returns milliseconds since epoch UTC

The now() method returns the milliseconds elapsed since 1 January 1970 00:00:00 UTC up until now as a Number.

To get that in Go, you can use:

time.Now().UTC().UnixNano() / 1e6
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download