I have a Java application where I get a timestamp with the call System.currentTimeInMills();
This returns values like 1331255526000.
Now I want to store these values in a MySQL database in a Datetime(6) field and I've written the following query:
$sql = 'INSERT INTO attention '. '(ParticipantID,SessionId, Timestamp, Attention) '. 'VALUES (' .$participant. ',' .$session. ',FROM_UNIXTIME(' .$timestamp. '),' .$attention. ')';
Where the variable $timestamp is the value I retrieve in Java.
However, this query is not working. What am I doing wrong?
use in mysql: from_unixtime($yourvariable / 1000)
Mysql timestamps are not in ms , but in seconds.