Home >Database >Mysql Tutorial >How Do I Convert MySQL Timestamps to Human-Readable Datetimes?

How Do I Convert MySQL Timestamps to Human-Readable Datetimes?

Susan Sarandon
Susan SarandonOriginal
2024-12-05 02:59:09761browse

How Do I Convert MySQL Timestamps to Human-Readable Datetimes?

Converting Timestamps to Datetimes in MySQL

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn