FAQ
I store date time using a simple call:

   time_value.String()

It works well and stores data like this:

   2011-09-04 15:54:42 -0700 PDT

Now, I need to parse that string back to time.Time struct:

   time.Parse(layout, string)

What layout should I pass?

Why do I even need to pass layout, if I used default layout to generate a
string in the 1st place?

--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Edward Muller at Jan 30, 2015 at 2:47 am
    I suggest reading: http://golang.org/pkg/time/#Time.String

    But here is an example: https://play.golang.org/p/Fsvo5UdMr1

    Also you may want to peruse this:
    https://golang.org/doc/effective_go.html#mixed-caps
    On Thu, Jan 29, 2015 at 6:09 PM, Sergei G wrote:

    I store date time using a simple call:

    time_value.String()

    It works well and stores data like this:

    2011-09-04 15:54:42 -0700 PDT

    Now, I need to parse that string back to time.Time struct:

    time.Parse(layout, string)

    What layout should I pass?

    Why do I even need to pass layout, if I used default layout to generate a
    string in the 1st place?

    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.


    --
    Edward Muller
    @freeformz

    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Dave Cheney at Jan 30, 2015 at 4:23 am
    See also, https://github.com/golang/go/issues/9596
    On Friday, 30 January 2015 13:09:32 UTC+11, Sergei G wrote:

    I store date time using a simple call:

    time_value.String()

    It works well and stores data like this:

    2011-09-04 15:54:42 -0700 PDT

    Now, I need to parse that string back to time.Time struct:

    time.Parse(layout, string)

    What layout should I pass?

    Why do I even need to pass layout, if I used default layout to generate a
    string in the 1st place?
    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Sergei G at Jan 31, 2015 at 12:43 am
    Thank you for pointing to the bug report. That is the issue and it is too
    late for Go to fix it.

    My solution is to use format explicitly:

    mystr := mytime.Format(time.RFC3339)
    time.Parse(time.RFC3339, mystr)

    On Thursday, January 29, 2015 at 8:23:27 PM UTC-8, Dave Cheney wrote:

    See also, https://github.com/golang/go/issues/9596
    On Friday, 30 January 2015 13:09:32 UTC+11, Sergei G wrote:

    I store date time using a simple call:

    time_value.String()

    It works well and stores data like this:

    2011-09-04 15:54:42 -0700 PDT

    Now, I need to parse that string back to time.Time struct:

    time.Parse(layout, string)

    What layout should I pass?

    Why do I even need to pass layout, if I used default layout to generate a
    string in the 1st place?
    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedJan 30, '15 at 2:09a
activeJan 31, '15 at 12:43a
posts4
users3
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase