Home >Database >Mysql Tutorial >How Do I Convert MySQL Timestamps to Human-Readable Datetimes?
When working with timestamps stored in MySQL, it often becomes necessary to convert them into human-readable datetime formats. One common scenario is converting timestamps to datetimes.
For instance, consider the timestamp 1300464000, which represents a specific point in time. To convert this timestamp into a datetime, we can use the FROM_UNIXTIME() function in MySQL.
SELECT FROM_UNIXTIME(1300464000);
This query will return the datetime "2011-03-18 16:00:00", which corresponds to the specified timestamp.
Note: If the timestamp is stored in milliseconds (e.g., in Java), remember to divide it by 1000 before using FROM_UNIXTIME() to obtain the correct Unix time in seconds.
The above is the detailed content of How Do I Convert MySQL Timestamps to Human-Readable Datetimes?. For more information, please follow other related articles on the PHP Chinese website!