Skip to content

Instantly share code, notes, and snippets.

@jordanorelli
Created April 24, 2012 18:59
Show Gist options
  • Save jordanorelli/2482728 to your computer and use it in GitHub Desktop.
Save jordanorelli/2482728 to your computer and use it in GitHub Desktop.
type Timestamp time.Time
func (t *Timestamp) UnmarshalJSON(b []byte) error {
i, err := strconv.ParseInt(string(b[1:len(b)-1]), 10, 0)
if err != nil {
log.Println("Unable to parse timestamp from json")
}
*t = Timestamp(time.Unix(i, 0))
return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment