1.
c# 里的 DateTime.toString 想要帶時區打印時有個巨坑,即 “yyyy-MM-dd HH:mm:ss zzz” 中的 "zzz" 不能用來表示時區,需要用 "K"
參考:
c# - Convert DateTime to specific timezone for ToString() - Stack Overflow
Custom date and time format strings | Microsoft Docs
Custom date and time format strings | Microsoft Docs
2. c# 的 DateTime.Parse 函數不支持指定時區讀取,需要讀取進來之后再轉時區。
3.c# 中的 datetime 想要轉換為 UTC時區,例如將 “2021-08-24T17:00:00-07:00” 轉為 “2021-08-25T00:00:00Z”,可以使用 DateTime.ToUniversalTime(),返回值是一個 DateTime對象
4. format 的時候,大寫的 H 是24 進制的小時,小寫的 h 是12 進制的小時,不要搞混了
5.像 零點零五分 0:05 表示為 12:05 ,一般是因為采用了12進制小時表示法