3.4 计算机时间元年

Posted cucy

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了3.4 计算机时间元年相关的知识,希望对你有一定的参考价值。


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

*/

以上是关于3.4 计算机时间元年的主要内容,如果未能解决你的问题,请参考以下文章