1 回答
TA贡献1786条经验 获得超11个赞
您需要的功能是time.Format. 将“myTime.String()”替换为“myTime.Format(layout)”,并将所需布局作为参数(例如,预定义的“time.RFC3339”或参考时间格式“2006-01-02 15:04:05.000000- 07")。
去文档:
func (t Time) Format(layout string) string
Format returns a textual representation of the time value formatted
according to layout, which defines the format by showing how the reference
time, defined to be
Mon Jan 2 15:04:05 -0700 MST 2006
would be displayed if it were the value; it serves as an example of the
desired output. The same display rules will then be applied to the time
value.
A fractional second is represented by adding a period and zeros to the end
of the seconds section of layout string, as in "15:04:05.000" to format a
time stamp with millisecond precision.
Predefined layouts ANSIC, UnixDate, RFC3339 and others describe standard and
convenient representations of the reference time. For more information about
the formats and the definition of the reference time, see the documentation
for ANSIC and the other constants defined by this package.
- 1 回答
- 0 关注
- 110 浏览
添加回答
举报