In case the textual representation of a time value is needed, usually, certain formatting is expected. The Time type of the time package provides the ability to create the string output in the given format. There are some rules on how to do this and we will cover a few useful ones.
Formatting date to string
How to do it...
- Open the console and create the folder chapter04/recipe02.
- Navigate to the directory.
- Create the format.go file with the following content:
package main
import (
"fmt"
"time"
)
func main() {
tTime := time.Date(2017, time.March, 5, 8, 5, 2, 0, time.Local)
// The formatting is done
// with use of reference value...