In this article we will learn about some of the frequently asked GO programming questions in technical like “Golang convert from ISO 8601 to milliseconds” Code Answer. When creating scripts and web applications, error handling is an important part. If your code lacks error checking code, your program may look very unprofessional and you may be open to security risks. Error or stack handling on go was simple and easy. An error message with filename, line number and a message describing the error is sent to the browser. This tutorial contains some of the most common error checking methods in GO. Below are some solution about “Golang convert from ISO 8601 to milliseconds” Code Answer.
Golang convert from ISO 8601 to milliseconds
xxxxxxxxxx
1
func main() {
2
// convert iso-8601 into rfc-3339 format
3
rfc3339t := strings.Replace("2015-12-23 00:00:00", " ", "T", 1) + "Z"
4
5
// parse rfc-3339 datetime
6
t, err := time.Parse(time.RFC3339, rfc3339t)
7
if err != nil {
8
panic(err)
9
}
10
11
// convert into unix time
12
ut := t.UnixNano() / int64(time.Millisecond)
13
14
fmt.Println(ut)
15
}