Golang time.Unix() function example
package time
Golang time.Unix() function usage example
package main
import (
"fmt"
"os"
"strconv"
"time"
)
func main() {
unixTimeStamp := "1432572732" // generate with Unix/Linux command >date +%s
unixIntValue, err := strconv.ParseInt(unixTimeStamp, 10, 64)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
timeStamp := time.Unix(unixIntValue, 0)
fmt.Println(timeStamp)
}
Output :
2015-05-25 16:52:12 +0000 UTC
Reference :
Advertisement
Something interesting
Tutorials
+6.9k How to let Facebook Login button redirect to a particular URL ?
+14.9k Golang : Basic authentication with .htpasswd file
+8.8k Golang : Random integer with rand.Seed() within a given range
+5.7k Golang : Error handling methods
+12.3k Golang : Display list of countries and ISO codes
+9.6k Golang : Read file with ioutil
+8.6k Python : Fix SyntaxError: Non-ASCII character in file, but no encoding declared
+10.3k Golang : Convert file content to Hex
+7.4k Golang : Scanf function weird error in Windows
+8k Golang : Sort words with first uppercase letter
+5.8k CodeIgniter/PHP : Remove empty lines above RSS or ATOM xml tag
+13.4k Golang : error parsing regexp: invalid or unsupported Perl syntax