Learn how to Convert Time to String in Golang

If you must convert Time to a String in Go, then you are able to do one of many following:

Possibility 1 – Utilizing time.Now#

package deal foremost

import (
    "fmt"
    "time"
)

func foremost() {
    currentTime := time.Now()
    fmt.Println("Time: ", currentTime.String())
}

Possibility 2 – Utilizing time.Time.String()#

package deal foremost

import (
    "fmt"
    "time"
)

func foremost() {
    Time := time.Date(2022, 03, 28, 03, 50, 16, 0, time.UTC)
    t := Time.String()
    fmt.Printf("Time with out the nano seconds: %vn", t)
}