Home > php教程 > php手册 > body text

mysql 查询 int类型日期转换成datetime类型

WBOY
Release: 2016-06-06 20:01:00
Original
1490 people have browsed it

1,数据库日期类型是int类型的,该查询结果是datetime类型的 SELECT from_unixtime( `dateline` ) FROM cdb_posts 2,如果原来类型是datetime类型,查询结果要是int类型则 SELECT unix_timestamp( `dateline` ) FROM cdb_posts 3,php时间转换,关键是看你在

1,数据库日期类型是int类型的,该查询结果是datetime类型的

SELECT from_unixtime( `dateline` ) FROM cdb_posts

 

2,如果原来类型是datetime类型,查询结果要是int类型则

SELECT unix_timestamp( `dateline` ) FROM cdb_posts

 

3,php时间转换,关键是看你在什么时候要获得对应的时间类型

$timestamp = 1210003200;
$datetime = date('Y-m-d H:i:s', $timestamp);
echo "该时间戳代表的时间:", $datetime, "
/n";
echo "从此时间重新转回时间戳:", strtotime($datetime), "
/n";

source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!