I know that there is a library for doing opposite. I need to format string, for example, "a year ago" to any date format "29/02/15".
This is tricky because those libraries (like timeago
) would also translate time in "less than a minute ago" (which you cannot translate back into an exact time)
For exact expressions (like "3 months ago"), you need to use time.AddDate()
(here t.AddDate(0, -3, 0).Month()
)
Then you can format the resulting time into any date format you want with Time.Format
or metakeule/fmtdate
.