Get Unix timestamp in Java, Python, Erlang
Mostly a note for myself. To Get Unix timestamp value in seconds
java:
long timestamp = System.currentTimeMillis()/1000
Python:
import time
timestamp = int(time.time())
Erlang:
{Mega, Secs, _} = now(),
Timestamp = Mega*1000000 + Secs,
Working with timestamps in MySQL
mysql> SELECT UNIX_TIMESTAMP('1997-10-04 22:23:00');
-> 875996580
mysql> SELECT FROM_UNIXTIME(1111885200);
+---------------------------+
| FROM_UNIXTIME(1111885200) |
+---------------------------+
| 2005-03-27 03:00:00 |
+---------------------------+
thank you =) your post is usefull for me.
tnx a lot)
Thanks for the Java time stamp!
The java method and the mysql method are inaccurate with each other. I’m using mysql server 5.0 and they often give results that are 1 hour apart (something to do with daylight savings time). WEEEAAAK
In order to avoid such issues I used to set timezone to UTC on all servers.
Thanks for the Timestamp in MySQL info!
thanks for python!