Created
May 13, 2015 16:59
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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