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 👍

Premium Content

You can get all the below premium content directly in your mail when you subscribe us

Books

Interview Questions

Soon You will get CSS, JavaScript, React Js, and TypeScript So Subscribe to it.

Portfolio Template

View | Get Source Code

Cheat Sheets

Cheat Sheets Books are basically Important useful notes which we use in our day-to-day life.

Related Posts