Humanizing Unix Timestamps with MySQL's FROM_UNIXTIME() Function
Question:
How can I convert Unix timestamps, stored in a MySQL database field, into human-readable date formats?
Answer:
To efficiently convert Unix timestamps into a user-friendly format within MySQL, leverage the built-in FROM_UNIXTIME() function. This powerful function allows you to transform timestamp values into human-readable date formats.
Syntax:
SELECT FROM_UNIXTIME(timestamp) FROM your_table;
Example:
Suppose you have a field named timestamp that stores Unix timestamps. To retrieve the corresponding human-readable dates, execute the following query:
SELECT FROM_UNIXTIME(`timestamp`) AS formatted_date FROM your_table;
This query returns a new column named formatted_date that contains the humanized dates.
Additional Information:
The above is the detailed content of How to Convert Unix Timestamps to Human-Readable Dates in MySQL?. For more information, please follow other related articles on the PHP Chinese website!