Go 的 time
包让我可以这样做:
time.Now().Format("2 January 2006")
返回类似 2009 年 11 月 10 日
的内容。
我可以使用 time
或任何标准 Go 程序包获得类似 2009 年 11 月 10 日
的信息吗?
time.Format文档没有提到它,我想避免 doing it manually如果可能的话。
最佳答案
内置的 time
库不支持它。您需要自己实现功能,使用链接的 Java 问题中描述的算法,或者使用可以为您完成的第三方库,例如 humanize
: https://godoc.org/github.com/dustin/go-humanize#Ordinal .
关于datetime - 如何在 Go 中获取序号指示符(第 1、第 2、第 3 等),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55850762/