OneCompiler

How to get current milliseconds in Go

How can I get current time in milliseconds in golang?

1 Answer

4 years ago by

Before version 1.17

func CurrentMilliseconds() int64 {
	return time.Now().UnixNano() / 1e6
}

From 1.17 and above

func CurrentMilliseconds() int64 {
	return time.Now().UnixMilli()
}
4 years ago by Karthik Divi