I try to use golang's time package to format some date with timezone from a SQL server, but found:
package main
import (
"time"
"fmt"
)
func main() {
loc, _ := time.LoadLocation("Asia/Shanghai")
endTime1 := time.Date(1, 1, 17, 23, 59, 59, 999*int(time.Millisecond), loc)
fmt.Printf("format string 1 : %s\n", endTime1.UTC().Format("2006-01-02T15:04:05.000Z"))
endTime2 := time.Date(2021, 1, 17, 23, 59, 59, 999*int(time.Millisecond), loc)
fmt.Printf("format string 2 : %s\n", endTime2.UTC().Format("2006-01-02T15:04:05.000Z"))
}
# output
format string 1 : 0001-01-17T15:54:16.999Z
format string 2 : 2021-01-17T15:59:59.999Z
The output's "HH:mm:ss" part is different. I finally found the key time is 1900-12-31, but not found any clue about that day from source code or the Internet.