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

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.

I'm working on some more Cheat Sheets book on Jquery, TypeScript, React js and for other languages. I will send it once it's completed.

Stay tuned working on React Js Cheat Sheets Book

Related Posts