Diff
Overview
Part of the time package — Node.js analog: moment, dayjs (package timex).
Signature
go
func Diff(a, b stdtime.Time) stdtime.DurationCompare: Node.js · Standard Go · gox
js
// Typical moment, dayjs (package timex) pattern in Node.jsgo
t := time.Now()
t.Format(time.RFC3339)go
import "github.com/sahilkhaire/gox/time"
gap := timex.Diff(deadline, time.Now())Example
go
import "github.com/sahilkhaire/gox/time"
gap := timex.Diff(deadline, time.Now())Tips
Import github.com/sahilkhaire/gox/time and call Diff 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)