mysql datetime(2) format from a golang utc time

208 views
Skip to first unread message

JM

unread,
Apr 18, 2016, 8:31:39 PM4/18/16
to golang-nuts
I'm struggling to get a utc datetime value in the format required by datetime(2) which must be like:
2014-09-08 17:51:04.78

I tried time.Now().UTC().Format(time.RFC3339) but it looks like:
2016-04-18T17:48:44-06:00

any ideas?
thanks.


Caleb Spare

unread,
Apr 18, 2016, 8:42:07 PM4/18/16
to JM, golang-nuts
You'll need to make your own format string.

"2006-01-02 15:04:05.00" should do the trick.


https://golang.org/pkg/time/#pkg-constants has more information about time formatting.

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

JM

unread,
Apr 19, 2016, 10:48:52 AM4/19/16
to golang-nuts, je...@magentatech.com
thank you, that worked. I tried that earlier but must have done something wrong.
thanks again.
Reply all
Reply to author
Forward
0 new messages