How to get current day in golang?

Hi Friends 👋,

Welcome To aGuideHub! ❤️

Today, we are going to learn how to get the current day number and print it in a golang console, here we will use the time package to get the day.

Basically, we will use the time.Now() method to get the current date, after that we use the Day() method to get the current day.

So, let’s start coding…

package main
import (

func main() {
  currentDay := time.Now().Day();

When you run the above code you will get the current day in your golang console, let’s check the output.

get, current day, golang

Try it yourself

All the best 👍

Follow me on Twitter