Last active
July 24, 2023 18:04
-
-
Save anyu/d648d2adb45dd799a54d5588b36f9de5 to your computer and use it in GitHub Desktop.
Revisions
-
anyu renamed this gist
Jul 24, 2023 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
anyu created this gist
Jul 24, 2023 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ package main import ( "fmt" "time" ) func main() { inputDate := "2023-03-10" inputTime := "00:00:00" locationName := "America/Los_Angeles" dateTimeStr := inputDate + " " + inputTime location, err := time.LoadLocation(locationName) if err != nil { fmt.Println("Error loading location:", err) return } parsedTime, err := time.ParseInLocation("2006-01-02 15:04:05", dateTimeStr, location) if err != nil { fmt.Println("Error parsing date and time:", err) return } unixTimestamp := parsedTime.Unix() fmt.Println("Date and Time:", parsedTime) fmt.Println("Unix Timestamp:", unixTimestamp) }