Created
November 15, 2023 03:17
-
-
Save obutora/808a2cf2593f5373a401bd58f863f849 to your computer and use it in GitHub Desktop.
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 characters
package main | |
import ( | |
"fmt" | |
"time" | |
) | |
func main() { | |
jst, _ := time.LoadLocation("Asia/Tokyo") | |
a, _ := time.Parse("2006-01-02 15:04:05", "2018-01-01 00:00:00") | |
b, _ := time.Parse("2006-01-02 15:04:05 (MST)", "2018-01-01 00:00:00 (JST)") | |
c, _ := time.ParseInLocation("2006-01-02 15:04:05", "2018-01-01 00:00:00", jst) | |
d, _ := time.ParseInLocation("2006-01-02 15:04:05 (MST)", "2018-01-01 00:00:00 (UTC)", jst) | |
fmt.Println("a: ", a) // 2018-01-01 00:00:00 +0000 UTC | |
fmt.Println("b: ", b) // 2018-01-01 00:00:00 +0900 JST | |
fmt.Println("c: ", c) // 2018-01-01 00:00:00 +0900 JST | |
fmt.Println("d: ", d) // 2018-01-01 00:00:00 +0000 UTC | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment