Web Development

Last time, we attempted to get the current date in Go Lang. We will get the current timestamp now.

Get current timestamp

package main

import (
  "fmt"
  "time"
)

func main() {
  now := time.Now()
  fmt.Println(now.Format("20060102150405"))
}
$ go run timestamp.go 
20151115133404

Get current timestamp in UTC

package main

import (
  "fmt"
  "time"
)

func main() {
  now := time.Now.UTC()
  fmt.Println(now.Format("20060102150405"))
}
$ go run timestamp.go 
20151115083531