Go-carbon v1.3.1 was released, adding diffforhumans () and i18n support

go-carbon is a simple,semantic and developer-friendly golang package for datetime

Difference for humans
// default locale is en
carbon.Now().DiffForHumans() // just now
carbon.Now().SubYears(1).DiffForHumans() // 1 years ago
carbon.Now().SubYears(2).DiffForHumans() // 2 year ago
carbon.Now().AddYears(1).DiffForHumans() // in 1 year
carbon.Now().AddYears(2).DiffForHumans() // in 2 years
// set locale to zh-CN
carbon.Now().SetLocale("zh-CN").DiffForHumans() // 刚刚
carbon.Now().SubMonths(1).SetLocale("zh-CN").DiffForHumans() // 1 月前
carbon.Now().AddMonths(2).SetLocale("zh-CN").DiffForHumans() // 2 月后

github:github.com/golang-module/carbon

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.