How to get the current date and time with milliseconds accuracy in Go

1 Answer

0 votes
package main

import (
        "fmt"
        "time"
)

func main() {
        now := time.Now()

        // Format the datetime string with milliseconds
        datetimeString := now.Format("2006-01-02 15:04:05.000")

        fmt.Println("Current datetime:", datetimeString)
}




/*
run:

Current datetime: 2024-12-06 15:15:16.715

*/

 



answered Dec 6, 2024 by avibootz
...