The same concept as the one used in date formatting is also used by date parsing. The same reference date and layout principles can be used. This recipe will show you how to transform the string input into a Time instance.
Parsing the string into date
How to do it...
- Open the console and create the folder chapter04/recipe03.
- Navigate to the directory.
- Create the parse.go file with the following content:
package main
import (
"fmt"
"time"
)
func main() {
// If timezone is not defined
// than Parse function returns
// the time in UTC timezone.
t, err := time.Parse("2/1/2006", "31/7/2015")
if err...