duanboniao5903
duanboniao5903
2017-02-25 01:44
浏览 47
已采纳

如何以特殊格式在golang中解析日期时间?

I has a special time string like this: February 24, 2017 , 1:44 pm and want to translate it to a golang time.Time object, does anyone know how to do this work. I have tried to using time.Parse(), but always got errors.

Thanks.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dongwen2896
    dongwen2896 2017-02-25 01:54
    已采纳

    Use the format string January 2, 2006 , 3:04 pm to parse that kind of string.

    Example: https://play.golang.org/p/4HgRekLr-7

    点赞 评论
  • douliexu5623
    douliexu5623 2017-02-27 10:15

    Read https://golang.org/pkg/time/#pkg-constants to know how to define your own formats or use predefined formates.

    点赞 评论

相关推荐