Convert a date/time into UTC

3,412 views
Skip to first unread message

ashleydw

unread,
Oct 30, 2014, 12:02:26 PM10/30/14
to golan...@googlegroups.com
Hi

I am looking for a way to convert a date/time into UTC, is there a package for such as thing?

I have found https://github.com/bcampbell/fuzzytime which allows me to parse times, but no conversion of `Time`.

I'm new to go, so may be missing something already built in?

Thanks

James Bardin

unread,
Oct 30, 2014, 12:19:33 PM10/30/14
to golan...@googlegroups.com

I'm new to go, so may be missing something already built in?

Brad Cook

unread,
Oct 30, 2014, 12:20:27 PM10/30/14
to golan...@googlegroups.com
Take a look at the "time" package.  Specifically, http://golang.org/pkg/time/#example_Parse and http://golang.org/pkg/time/#Time.UTC.

ashleydw

unread,
Oct 30, 2014, 12:59:16 PM10/30/14
to golan...@googlegroups.com
Thanks for the answers, can't believe i missed time.parse. However, it seems I can't get it to parse a timezone?: http://play.golang.org/p/cyjtYSFb4w

Michael Hofmann

unread,
Oct 30, 2014, 1:37:04 PM10/30/14
to golan...@googlegroups.com
time.Parse expects the (fixed) reference time formatted according to
your scheme as its first parameter.

Scott Whitworth

unread,
Oct 30, 2014, 1:41:28 PM10/30/14
to ashleydw, golan...@googlegroups.com
You need to use the reference time (Mon Jan 2 15:04:05 -0700 MST 2006).
> --
> 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.

DisposaBoy

unread,
Oct 30, 2014, 1:41:44 PM10/30/14
to golan...@googlegroups.com
For the layout you need to type the *reference time*. I can't write a good example right now, but the docs should be enough once the idea clicks. E.g. where you have 12:00:00 in the layout, you probably want 15:04:05
Reply all
Reply to author
Forward
0 new messages