Parsing Time in Golang Last Updated : 08 Jun, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report Parsing time is to convert our time to Golang time object so that we can extract information such as date, month, etc from it easily. We can parse any time by using time.Parse function which takes our time string and format in which our string is written as input and if there is no error in our format, it will return a Golang time object. Examples: Input : "2018-04-24" Output : 2018-04-24 00:00:00 +0000 UTC Input : "04/08/2017" Output : 2017-04-08 00:00:00 +0000 UTC Code: C // Golang program to show the parsing of time package main import ( "fmt" "time" ) func main() { // The date we're trying to // parse, work with and format myDateString := "2018-01-20 04:35" fmt.Println("My Starting Date:\t", myDateString) // Parse the date string into Go's time object // The 1st param specifies the format, // 2nd is our date string myDate, err := time.Parse("2006-01-02 15:04", myDateString) if err != nil { panic(err) } // Format uses the same formatting style // as parse, or we can use a pre-made constant fmt.Println("My Date Reformatted:\t", myDate.Format(time.RFC822)) // In YY-MM-DD fmt.Println("Just The Date:\t\t", myDate.Format("2006-01-02")) } Output: My Starting Date: 2018-01-20 04:35 My Date Reformatted: 20 Jan 18 04:35 UTC Just The Date: 2018-01-20 Comment More infoAdvertise with us Next Article Parsing Time in Golang M Mayank Rana 1 Follow Improve Article Tags : Go Language GoLang-time Similar Reads Time Durations in Golang Operations related to time and date are a crucial part of software development (example log keeping). Go standard library provides a time package that has many functions and methods to deal with date and time. The operating system measures two types of time "Wall clock" time and "Monotonic" time. Wa 3 min read Time Formatting in Golang Golang supports time formatting and parsing via pattern-based layouts. To format time, we use the Format() method which formats a time.Time object. Syntax: func (t Time) Format(layout string) string We can either provide custom format or predefined date and timestamp format constants are also availa 2 min read How to Print Specific date-time in Golang? Golang supports time formatting and parsing via pattern-based layouts. In Go, the current time can be determined by using time.Now(), provided by the time package. Package time provides functionality for measuring and displaying the time. To print Current date-time you need to import the "time" pack 2 min read time.Parse() Function in Golang With Examples In Go language, time packages supplies functionality for determining as well as viewing time. The Parse() function in Go language is used to parse a formatted string and then finds the time value that it forms. Moreover, this function is defined under the time package. Here, you need to import "time 2 min read time.String() Function in Golang With Examples In Go language, time packages supplies functionality for determining as well as viewing time. The String() function in Go language is used to find a string that represents the duration formats as "24h6m0.7s". Here, the foremost zero units are deleted. And the stated duration with less than one-secon 2 min read Like