Answers for "rfc3339 format go"

Go
1

golang sleep

package main

import (
    "fmt"
    "time"
)

func main() {
    fmt.Printf("Current Unix Time: %vn", time.Now().Unix())

    time.Sleep(2 * time.Second)

    fmt.Printf("Current Unix Time: %vn", time.Now().Unix())
}
Posted by: Guest on November-28-2020
0

golang time format with milliseconds

//Golang format datetime to string with miliseconds
package main

import (
	"fmt"
	"time"
)

func main() {
	timeFormatMilisecondsWithTrailingZero()
	timeFormatMilisecondsWithoutTrailingZero()
}

func timeFormatMilisecondsWithTrailingZero() {
	//2020-10-22 14:30:29.250
	fmt.Println(time.Now().Format("2006-01-02 15:04:05.000"))

}
func timeFormatMilisecondsWithoutTrailingZero() {
	//2020-10-22 14:30:29.25
	fmt.Println(time.Now().Format("2006-01-02 15:04:05.999"))
}
Posted by: Guest on October-22-2020

Browse Popular Code Answers by Language