Convert date to timestamp by Golang

What is Unix timestamp ?

Unix timestamp is 64 bit value represents current time since 1 January 1970

Golang time.Now() returns current DateTime object

Getting timestamp in Golang
currentTime := time.Now()
fmt.Println(currentTime.Unix())

> 1738148999

UnixMilli
currentTime := time.Now()
fmt.Println(currentTime.UnixMilli())

> 1738149111065

UnixMicro
currentTime := time.Now()
fmt.Println(currentTime.UnixMicro())

> 1738149141680690

UnixNano
currentTime := time.Now()
fmt.Println(currentTime.UnixNano())

> 1738149218711926000

Rate Post :
Similar Posts :
Comments :

Message length should be less than 1024 character!