Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I have a timestamp which I am getting using time.Now().Format(time.RFC3339) . The format is 2018-10-17T07:26:33Z However, I want the format in ISO 8601: 2018-10-17T07:26:33.000Z

How do I get those extra milliseconds in the end ?

//2018-10-17T07:26:33.000Z required //Layouts must use the reference time Mon Jan 2 15:04:05 MST 2006 fmt.Println(t1.Format("2006-01-02T15:04:05.000Z"))

playground link (good idea Sunny) https://play.golang.org/p/Y3II7lGZB-D

t := time.Now()
var fdatevalue string
// outstr = fmt.Sprintf("%02d%02d%02d%02d%02d", t.Month(), t.Day(), t.Hour(),       t.Minute(), t.Second())
fdatevalue=fmt.Sprintf("%02d%02d%2dT%2d:%2d:%2d", t.Year() , t.Month(), t.Day() , t.Hour(),t.Minute(),t.Second)
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.