Convert mysql DATETIME column to epoch seconds

后端 未结 2 548
旧时难觅i
旧时难觅i 2020-12-20 11:05

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 th

相关标签:
2条回答
  • 2020-12-20 11:44

    Use MySQL's UNIX_TIMESTAMP function

    0 讨论(0)
  • 2020-12-20 11:54

    You can use :

    SELECT UNIX_TIMESTAMP(yourfield) FROM yourtable;
    

    And for UPDATE, the invers function is : FROM_UNIXTIME(...)

    0 讨论(0)
提交回复
热议问题