How to print current timestamp in golang?

Hi Friends 👋,

Welcome To aGuideHub! ❤️

Today, we are going to learn how to print the current timestamp in golang?. here, we will use the time package to get the current timestamp and the fmt package for the print timestamp.

So, first, we will create a now variable and store the current timestamp, after that we will pass this variable in the fmt.Println() method.

Let’s dive into code…

package main
import (
	"time"
	"fmt"
)

func main() {
now := time.Now()
fmt.Println(now)  
}

When you run the above program, you will get the current timestamp in the golang console.

print, current timestamp, golang

Try it yourself

All the best 👍

Follow me on Twitter