Skip to content

Instantly share code, notes, and snippets.

@yiting007
Created May 13, 2015 16:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yiting007/2f7d3603874ade1d694c to your computer and use it in GitHub Desktop.
Save yiting007/2f7d3603874ade1d694c to your computer and use it in GitHub Desktop.
Convert a given string to date then see if it is before or after now
package main
import (
"fmt"
"time"
)
func main() {
layout := "01/02/2006, 03:04PM"
val := "05/13/2015, 12:00PM"
loc, _ := time.LoadLocation("America/Dawson")
t, _ := time.ParseInLocation(layout, val, loc)
fmt.Println(t)
fmt.Println(time.Now())
fmt.Println(t.Before(time.Now()))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment