date format golang
input := "2017-08-31"
layout := "2006-01-02"
t, _ := time.Parse(layout, input)
fmt.Println(t) // 2017-08-31 00:00:00 +0000 UTC
fmt.Println(t.Format("02-Jan-2006")) // 31-Aug-2017
date format golang
input := "2017-08-31"
layout := "2006-01-02"
t, _ := time.Parse(layout, input)
fmt.Println(t) // 2017-08-31 00:00:00 +0000 UTC
fmt.Println(t.Format("02-Jan-2006")) // 31-Aug-2017
go packae unix time
package main
import (
"fmt"
"time"
)
func unixtime() {
fmt.Println(time.Now().Unix())
}
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"))
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us