Go Pretty Time

Go Report Card Build Status GoDoc CodeCov

Format Go date time in a pretty way. ex : just now, a minute ago, 2 hours ago , 3 minutes ago

Inspired by the John Resig Pretty Date plug-in for JQuery

prettytime.Format("2008-01-28T20:24:17Z") // => "2 hours ago"
prettytime.Format("2008-01-27T22:24:17Z") // => "Yesterday"
prettytime.Format("2008-01-26T22:24:17Z") // => "2 days ago"
prettytime.Format("2008-01-14T22:24:17Z") // => "2 weeks ago"


go get github.com/andanhm/go-prettytime


package main

import (


const (
    layout = "2006-01-02T15:04:05Z"

func main() {
    t, err := time.Parse(layout, "2008-01-28T20:24:17Z")
    if err != nil {
    log.Printf("%s \n", prettytime.Format(t))
// Output: 13 years ago

i18n support

go-prettytime uses go-i18n to provide i18n capabilities.

Translating a new language

Create an empty message file for the language that you want to add (e.g. translate.es.toml).

Run goi18n merge en.toml translate.es.toml to populate translate.es.toml with the messages to be translated.

After translate.es.toml has been translated, rename it to es.toml

Load es.toml into the time.go file via



Feel free to fork and add features, fix bugs and your pull request is more than welcome ❤

Go Prettytime

Format GoLang dates in a “pretty” way. ex : just now, a minute ago, 2 hours ago , 3 minutes ago

Go Prettytime Info

⭐ Stars 20
🔗 Source Code github.com
🕒 Last Update 9 months ago
🕒 Created 5 years ago
🐞 Open Issues 1
➗ Star-Issue Ratio 20
😎 Author andanhm