time.Time.AppendFormat() Function in Golang With Examples Last Updated : 19 Apr, 2020 Comments Improve Suggest changes Like Article Like Report In Go language, time packages supplies functionality for determining as well as viewing time. The Time.AppendFormat() function in Go language is like Format() method but this method also appends the stated textual representation to the stated "b". Moreover, this function is defined under the time package. Here, you need to import the "time" package in order to use these functions. Syntax: func (t Time) AppendFormat(b []byte, layout string) []byte Here, "t" is the stated time, "b" is the byte of slice and layout holds a string type. Return value: It appends the textual representation to the "b" and then returns the buffer that is extended. Example 1: C // Golang program to illustrate the usage of // Time.AppendFormat() function // Including main package package main // Importing fmt and time import "fmt" import "time" // Calling main func main() { // Declaring Time Time := time.Date(2019, time.January, 1, 3, 0, 0, 0, time.UTC) // Defining byte of slice b := []byte("The time is: ") // Calling AppendFormat method with // its parameter b = Time.AppendFormat(b, "03:00PM") // Prints buffer fmt.Println(b) } Output: [84 104 101 32 116 105 109 101 32 105 115 58 32 48 51 58 48 48 65 77] Here, textual representation of time is appended to the "b" then its returned as a buffer. Example 2: C // Golang program to illustrate the usage of // Time.AppendFormat() function // Including main package package main // Importing fmt and time import "fmt" import "time" // Calling main func main() { // Declaring Time Time := time.Date(2019, time.January, 1, 3, 0, 0, 0, time.UTC) // Defining byte of slice b := []byte("The time is: ") // Calling AppendFormat method with // its parameter b = Time.AppendFormat(b, time.Kitchen) // Prints string fmt.Println(string(b)) } Output: The time is: 3:00AM Here, a predefined layout is used that is, time.Kitchen which is used in Time.Format. And in the above output a string is returned instead of buffer as string() method is used here to convert a buffer into the string. Comment More infoAdvertise with us Next Article time.Time.AppendFormat() Function in Golang With Examples nidhi1352singh Follow Improve Article Tags : Go Language GoLang-time Similar Reads time.Time.AddDate() Function in Golang with Examples In Go language, time packages supplies functionality for determining as well as viewing time. The Time.AddDate() function in Go language is used to check the time which is equivalent to adding the stated number of years, months, and days to the given "t". For example, if the parameters of the method 3 min read time.Time.Date() Function in Golang with Examples In Go language, time packages supplies functionality for determining as well as viewing time. The Time.Date() function in Go language is used to check the year, month, and day in which the stated "t" presents itself. Moreover, this function is defined under the time package. Here, you need to import 2 min read time.Time.Before() Function in Golang With Examples In Go language, time packages supplies functionality for determining as well as viewing time. The Time.Before() function in Go language is used to check if the stated time instant t is before the stated u or not. Moreover, this function is defined under the time package. Here, you need to import the 2 min read time.Time.Add() Function in Golang with Examples In Go language, time packages supplies functionality for determining as well as viewing time. The Time.Add() function in Go language is used to add the stated time and duration. Moreover, this function is defined under the time package. Here, you need to import the "time" package in order to use the 2 min read time.Time.After() Function in Golang With Examples In Go language, time packages supplies functionality for determining as well as viewing time. The Time.After() function in Go language is used to check if the stated time instant t is after the stated u or not. Moreover, this function is defined under the time package. Here, you need to import the " 2 min read time.Time.Day() Function in Golang With Examples In Go language, time packages supplies functionality for determining as well as viewing time. The Time.Day() function in Go language is used to check the day of the month in which the stated "t" presents itself. Moreover, this function is defined under the time package. Here, you need to import the 2 min read time.Time.Equal() Function in Golang With Examples In Go language, time packages supplies functionality for determining as well as viewing time. The Time.Equal() function in Go language is used to check if the stated times "t" and "u" represents identical time instant or not. And two times located in different locations can even be equal. Moreover, 2 min read time.Time.Clock() Function in Golang With Examples In Go language, time packages supplies functionality for determining as well as viewing time. The Time.Clock() function in Go language is used to check the hour, minute, and second within the day in which the stated "t" presents itself. Moreover, this function is defined under the time package. Here 2 min read time.Date() Function in Golang With Examples In Go language, time packages supplies functionality for determining as well as viewing time. The Date() function in Go language is used to find Date the Time which is equivalent to yyyy-mm-dd hh:mm:ss + nsec nanoseconds in the proper time zone in the stated location. Moreover, this function is defi 2 min read time.Time.In() Function in Golang with Examples In Go language, time packages supplies functionality for determining as well as viewing time. The In() function in Go language is used to find a copy of the stated "t" that represents the identical time instant, but along with the copy's location data that is set to "loc" for display uses. And if "l 2 min read Like