How to format time.Since().String()?

What I have -> 1m16.044455998s

What I want -> 1m16s without milli-, micro-, nano- seconds.

Upvotes: 1

Views: 907

Answers (1)

Saurav Prakash
Saurav Prakash

Reputation: 1949

Use this

time.Since(t1).Truncate(time.Second).String()

Check this go playground link for an example: https://play.golang.org/p/x7k9zuuqpRp

Upvotes: 6

Related Questions