Format
Overview
If you are coming from Node.js, the closest pattern is moment().format().
Signature
go
func Format(t stdtime.Time, layout string) stringCompare: Node.js · Standard Go · gox
js
moment().format()go
t := time.Now()
t.Format(time.RFC3339)go
import "github.com/sahilkhaire/gox/time"
timex.Format(t, layout)Example
go
import "github.com/sahilkhaire/gox/time"
timex.Format(t, layout)Tips
Import github.com/sahilkhaire/gox/time and call Format directly. See the comparison below for the standard library equivalent.
Standard library alternative
Use the standard library directly:
go
t := time.Now()
t.Format(time.RFC3339)