Skip to content

Instantly share code, notes, and snippets.

@bsdlp
Created June 8, 2016 08:18
Show Gist options
  • Save bsdlp/f0c633bfb3d8cf69ba845d71ee9b74ab to your computer and use it in GitHub Desktop.
Save bsdlp/f0c633bfb3d8cf69ba845d71ee9b74ab to your computer and use it in GitHub Desktop.
jchen@locke-(master|✔)> GOOS=linux GOARCH=amd64 go build time.go ~/src/github.com/bsdlp/go-sandbox
[126] jchen@locke-(master|✔)> scp time control:~/ ~/src/github.com/bsdlp/go-sandbox
time 100% 2240KB 2.2MB/s 00:01
jchen@locke-(master|✔)> go run time.go ~/src/github.com/bsdlp/go-sandbox
20160608T005827Z
20160608
jchen@locke-(master|✔)> ssh control './time' ~/src/github.com/bsdlp/go-sandbox
20160608T075827Z
20160608
jchen@locke-(master|✔)> cat time.go ~/src/github.com/bsdlp/go-sandbox
package main
import (
"fmt"
"time"
)
const (
format1 = "20060102T150405Z"
format2 = "20060102"
unixTime = 1465372707
)
func main() {
t := time.Unix(unixTime, 0)
fmt.Println(t.Format(format1))
fmt.Println(t.Format(format2))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment