rfc3339 format go code example
Example 1: golang sleep
package main
import (
"fmt"
"time"
)
func main() {
fmt.Printf("Current Unix Time: %v\n", time.Now().Unix())
time.Sleep(2 * time.Second)
fmt.Printf("Current Unix Time: %v\n", time.Now().Unix())
}
Example 2: golang time format with milliseconds
package main
import (
"fmt"
"time"
)
func main() {
timeFormatMilisecondsWithTrailingZero()
timeFormatMilisecondsWithoutTrailingZero()
}
func timeFormatMilisecondsWithTrailingZero() {
fmt.Println(time.Now().Format("2006-01-02 15:04:05.000"))
}
func timeFormatMilisecondsWithoutTrailingZero() {
fmt.Println(time.Now().Format("2006-01-02 15:04:05.999"))
}