package main

import (
	"fmt"
	"time"
)

func main() {

	// Set the epoch from int64
	t := time.Unix(0, 0)
	fmt.Println(t)

	// Get the epoch
	// from Time instance
	epoch := t.Unix()
	fmt.Println(epoch)

	// Current epoch time
	apochNow := time.Now().Unix()
	fmt.Printf("Epoch time in seconds: %d\n", apochNow)

	apochNano := time.Now().UnixNano()
	fmt.Printf("Epoch time in nano-seconds: %d\n", apochNano)

}

/*
1970-01-01 08:00:00 +0800 CST
0
Epoch time in seconds: 1521649376
Epoch time in nano-seconds: 1521649376346176000

*/

相关文章:

  • 2021-12-27
  • 2022-02-09
  • 2022-12-23
  • 2021-04-07
  • 2022-12-23
  • 2021-07-20
  • 2022-12-23
猜你喜欢
  • 2021-06-15
  • 2021-09-25
  • 2021-08-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-27
相关资源
相似解决方案