Getting Epoch Timestamp in C

Posted on

In C, how to get the epoch timestamp, the number of seconds passed since the epoch? In C, from man 7 time: UNIX systems represent time in seconds since the Epoch, 1970-01-01 00:00:00 +0000 (UTC). A program can determine the calendar time using gettimeofday(2), which returns time (in seconds and microseconds) that have elapsed since
Read more

How to convert epoch timestamp to human readable date format in Python?

Posted on

How to convert an epoch timestamp to a human readable date format? In Python: import time time.strftime(“%a, %d %b %Y %H:%M:%S %Z”, time.localtime(epoch)) One example: $ python Python 2.7.5 (default, Nov 6 2016, 00:28:07) [GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux2 Type “help”, “copyright”, “credits” or “license” for more information. >>> import time >>>
Read more

How to get the epoch timestamp in Java?

Posted on

In Java, how to get the epoch timestamp, the number of seconds passed since the epoch? In Java, you can get the current time in milliseconds and then calculate the epoch time: long ts = System.currentTimeMillis()/1000; Example: $ wget –quiet https://github.com/albertlatacz/java-repl/releases/download/428/javarepl-428.jar -O /tmp/javarepo-428.jar && java -jar /tmp/javarepo-428.jar Welcome to JavaREPL version 428 (Java HotSpot(TM) 64-Bit
Read more

How to get the epoch timestamp in Go lang?

Posted on

In Go lang, how to get the epoch timestamp, the number of seconds passed since the epoch? In Go, you can use the time.Now() func to get current time and its Unix() func to convert it into an epoch timestamp: import(“time”) func getEpochTime() int64 { return time.Now().Unix() } If you would convert a time string
Read more