Get current time as formatted string in Go?

后端 未结 8 529
北荒
北荒 2021-01-30 01:15

What\'s the best way to get the current timestamp in Go and convert to string? I need both date and time in eg. YYYYMMDDhhmmss format.

8条回答
  •  闹比i
    闹比i (楼主)
    2021-01-30 01:53

    To answer the exact question:

    import "github.com/golang/protobuf/ptypes"
    
    Timestamp, _ = ptypes.TimestampProto(time.Now())
    

提交回复
热议问题