FAQ
I am trying to format current time using time package. However seconds are
not appearing properly. PFB the code for the same:

  package mainimport (
     "time"
     "fmt")
  var week time.Duration
func main() {
     t := time.Now()
     fmt.Println(t.Format("02 Jan 2006 15:04:15"))}

However, if i change format to :

fmt.Println(t.Format("02 Jan 2006 15:04:05"))

Seconds start appearing properly. Why seconds should end with 05 or 50 ?

--
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

  • Thomas Bushnell, BSG at Apr 1, 2015 at 1:26 am
    Because the reference time is 15:04:05, not 15:04:15.

    Thomas
    On Tue, Mar 31, 2015 at 6:24 PM wrote:

    I am trying to format current time using time package. However seconds are
    not appearing properly. PFB the code for the same:

    package mainimport (
    "time"
    "fmt")
    var week time.Duration
    func main() {
    t := time.Now()
    fmt.Println(t.Format("02 Jan 2006 15:04:15"))}

    However, if i change format to :

    fmt.Println(t.Format("02 Jan 2006 15:04:05"))

    Seconds start appearing properly. Why seconds should end with 05 or 50 ?

    --
    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.
    --
    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.
  • Caleb Spare at Apr 1, 2015 at 1:27 am
    The reference time is Mon Jan 2 15:04:05 MST 2006, not Mon Jan 2 15:04:15
    MST 2006. Format (and time.Parse) use the reference time.

    Read through http://golang.org/pkg/time/#pkg-constants for more info.
    On Tue, Mar 31, 2015 at 5:35 PM, wrote:

    I am trying to format current time using time package. However seconds are
    not appearing properly. PFB the code for the same:

    package mainimport (
    "time"
    "fmt")
    var week time.Duration
    func main() {
    t := time.Now()
    fmt.Println(t.Format("02 Jan 2006 15:04:15"))}

    However, if i change format to :

    fmt.Println(t.Format("02 Jan 2006 15:04:05"))

    Seconds start appearing properly. Why seconds should end with 05 or 50 ?

    --
    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.
    --
    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.
  • Matthew Zimmerman at Apr 1, 2015 at 3:05 am
    And even *more* information - https://golang.org/src/time/format.go#L62
    On Tue, Mar 31, 2015 at 9:27 PM Caleb Spare wrote:

    The reference time is Mon Jan 2 15:04:05 MST 2006, not Mon Jan 2 15:04:15
    MST 2006. Format (and time.Parse) use the reference time.

    Read through http://golang.org/pkg/time/#pkg-constants for more info.
    On Tue, Mar 31, 2015 at 5:35 PM, wrote:

    I am trying to format current time using time package. However seconds
    are not appearing properly. PFB the code for the same:

    package mainimport (
    "time"
    "fmt")
    var week time.Duration
    func main() {
    t := time.Now()
    fmt.Println(t.Format("02 Jan 2006 15:04:15"))}

    However, if i change format to :

    fmt.Println(t.Format("02 Jan 2006 15:04:05"))

    Seconds start appearing properly. Why seconds should end with 05 or 50 ?

    --
    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.
    --
    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.
    --
    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.
  • Rob Pike at Apr 1, 2015 at 4:06 am
    And *still* more information -
    http://tip.golang.org/pkg/time/#example_Time_Format

    -rob

    On Tue, Mar 31, 2015 at 8:05 PM, Matthew Zimmerman wrote:

    And even *more* information - https://golang.org/src/time/format.go#L62
    On Tue, Mar 31, 2015 at 9:27 PM Caleb Spare wrote:

    The reference time is Mon Jan 2 15:04:05 MST 2006, not Mon Jan 2 15:04:15
    MST 2006. Format (and time.Parse) use the reference time.

    Read through http://golang.org/pkg/time/#pkg-constants for more info.
    On Tue, Mar 31, 2015 at 5:35 PM, wrote:

    I am trying to format current time using time package. However seconds
    are not appearing properly. PFB the code for the same:

    package mainimport (
    "time"
    "fmt")
    var week time.Duration
    func main() {
    t := time.Now()
    fmt.Println(t.Format("02 Jan 2006 15:04:15"))}

    However, if i change format to :

    fmt.Println(t.Format("02 Jan 2006 15:04:05"))

    Seconds start appearing properly. Why seconds should end with 05 or 50 ?

    --
    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.
    --
    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.
    --
    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.
    --
    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
postedApr 1, '15 at 1:24a
activeApr 1, '15 at 4:06a
posts5
users5
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase