How does one convert seconds (or milliseconds) to a timestamp (or just a string that looks like a date) in mySql

后端 未结 4 678
南笙
南笙 2021-01-18 03:35

I\'m looking at this documentation http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_maketime And I KNOW I must be missing it, but I just don\'t s

4条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-18 04:14

    First off, what do you mean by passing seconds to retrieve a timestamp? Aren't the seconds the timestamp already?

    Secondly, you are looking for this function if you want to do this in SQL: http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_date-format

    Thirdly, you may want to consider just retrieving the timestamp from the database, and letting the application (e.g., in PHP, I don't know which language you're using) turn it into the required format. If you're consistent in this design it allows you to more generically define your date formats.

提交回复
热议问题