In JavaScript, I can assign:
var now = Date.now();
Then use now
to calculate as a number variable
time.Time
type in Go doesn't seem to meet this demand. What is the Go equivalent of JavaScript's Date.now()
?
In JavaScript, I can assign:
var now = Date.now();
Then use now
to calculate as a number variable
time.Time
type in Go doesn't seem to meet this demand. What is the Go equivalent of JavaScript's Date.now()
?
Date.now()
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