To get the current timestamp in Golang, you can use the “time.Now().Unix()” function. The time.Unix() function is a method of the time.Time type in Go, which represents a time value.
The time.Unix() function returns the Unix time, which is the number of seconds elapsed since January 1, 1970, UTC, and the time.Now() function returns a time.Time type, which contains both the date and time.
Example
package main
import (
"fmt"
"time"
)
func main() {
timestamp := time.Now().Unix()
fmt.Println("The current timestamp is:", timestamp)
}
Output
The current timestamp is: 1676117332
You can see that we got the current timestamp in seconds using the time.Now().Unix() function.
How to get the current time in Go
To get the current time in Golang, you can use the time.Now() function like this: time.Now().
package main
import (
"fmt"
"time"
)
func main() {
tme := time.Now()
fmt.Println("The current time is:", tme)
}
Output
The current time is: 2023-02-11 17:48:33.002301 +0530 IST m=+0.000221043
That’s it.

Krunal Lathiya is a seasoned Computer Science expert with over eight years in the tech industry. He boasts deep knowledge in Data Science and Machine Learning. Versed in Python, JavaScript, PHP, R, and Golang. Skilled in frameworks like Angular and React and platforms such as Node.js. His expertise spans both front-end and back-end development. His proficiency in the Python language stands as a testament to his versatility and commitment to the craft.