Standard library / time
time.Time.AppendFormat()
Append formatted time to the supplied byte slice; keep the returned slice because allocation may occur. Expected stdout: 'date=2024-02-29\n'.
Formal Syntax & Structure
go syntaxgo
func (t Time) AppendFormat(b []byte, layout string) []byteParameters & Attributes
| Name | Type | Description |
|---|---|---|
| b | []byte | Destination byte slice to append to. |
| layout | string | Go reference-time layout string. |
Return Value
[]byte
Append formatted time to the supplied byte slice; keep the returned slice because allocation may occur.
Working Example
Example Snippetgo
package main
import ( "fmt" "time")
func fixed() time.Time { return time.Date(2024, 2, 29, 12, 34, 56, 123000000, time.UTC) }func main() { fmt.Println(string(fixed().AppendFormat([]byte("date="), time.DateOnly))) }