问题
I have a column mysql datetime
that is in DATETIME format.
Is there a way to SELECT
this column in epoch seconds? If not, what would be the best way of converting the datetime format to epoch seconds? What type of field would be the best to capture this?
回答1:
Use MySQL's UNIX_TIMESTAMP function
回答2:
You can use :
SELECT UNIX_TIMESTAMP(yourfield) FROM yourtable;
And for UPDATE, the invers function is : FROM_UNIXTIME(...)
来源:https://stackoverflow.com/questions/10839151/convert-mysql-datetime-column-to-epoch-seconds