remove number for source
This commit is contained in:
23
src/epochs/epochs.go
Normal file
23
src/epochs/epochs.go
Normal file
@@ -0,0 +1,23 @@
|
||||
// ## Epochs
|
||||
|
||||
// A common requirement in programms is getting the number
|
||||
// of seconds, milliseconds, or nanoseconds since the Unix
|
||||
// epoch. Here's how to do it in Go.
|
||||
|
||||
package main
|
||||
|
||||
import "time"
|
||||
|
||||
func main() {
|
||||
// Use `time.Now` with `Unix` or `UnixNano` to get
|
||||
// elapsed time since the Unix epoch.
|
||||
now := time.Now()
|
||||
secs := now.Unix()
|
||||
nanos := now.UnixNano()
|
||||
|
||||
// Note that there is no `UnixMillis`.
|
||||
millis := nanos / 1000000
|
||||
println("Secs: ", secs)
|
||||
println("Millis:", millis)
|
||||
println("Nanos: ", nanos)
|
||||
}
|
||||
4
src/epochs/epochs.sh
Normal file
4
src/epochs/epochs.sh
Normal file
@@ -0,0 +1,4 @@
|
||||
$ go run epochs.go
|
||||
Secs: 1348240948
|
||||
Millis: 1348240948517
|
||||
Nanos: 1348240948517870000
|
||||
Reference in New Issue
Block a user