Reputation: 2845
This query in MySQL:
UPDATE my_table SET last_active = 100000 WHERE my_id = 1;
sets the last_active field, which is of type TIMESTAMP, to "0000-00-00 00:00:00", but I'd expect it to set it to 100000 seconds past 1970. How can I do that?
Upvotes: 0
Views: 253
Reputation: 437
Convert from epoch to date
FROM_UNIXTIME(epoch timestamp, optional output format)
The default output is YYY-MM-DD HH:MM:SS
For your code:
UPDATE my_table SET last_active = FROM_UNIXTIME(100000) WHERE my_id = 1;
Upvotes: 1