且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 MySQL 中将时间戳转换为日期时间?

更新时间:2023-01-22 12:06:44

使用 FROM_UNIXTIME() MySQL 中的函数

Use the FROM_UNIXTIME() function in MySQL

请记住,如果您使用的框架以毫秒为单位存储它(例如 Java 的时间戳),您必须除以 1000 以获得正确的 Unix 时间(以秒为单位).

Remember that if you are using a framework that stores it in milliseconds (for example Java's timestamp) you have to divide by 1000 to obtain the right Unix time in seconds.