Skip to content

Instantly share code, notes, and snippets.

@tmlbl
Created December 8, 2014 08:19
Show Gist options
  • Save tmlbl/a9d8aed11fc6f3ff0ce6 to your computer and use it in GitHub Desktop.
Save tmlbl/a9d8aed11fc6f3ff0ce6 to your computer and use it in GitHub Desktop.
How to get time in past in Golang https://play.golang.org/p/ROTLEXldq4
package main
import (
"fmt"
"time"
)
func main() {
now := time.Now()
oneMonthAgo := time.Unix(now.Unix() - (60 * 60 * 24 * 30), 0)
fmt.Println(now)
fmt.Println(oneMonthAgo)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment