Answers for "golang time difference in milliseconds"

Go
1

golang time difference in milliseconds

package main
import (
        "log"
        "time"
)
func main() {
        start := time.Now().UnixNano() / int64(time.Millisecond)
        // do something
        time.Sleep(1 * time.Second)
        end := time.Now().UnixNano() / int64(time.Millisecond)
        diff := end - start
        log.Printf("Duration(ms): %d", diff)
}
Posted by: Guest on April-06-2021

Browse Popular Code Answers by Language