急急PHP,数据库中createtime字段类型为datetime,怎样根据这个查询一段时间内的数据

WBOY
Release: 2016-06-23 14:00:25
Original
1193 people have browsed it

数据库中createtime字段类型为datetime,是年月日时分秒,怎样把他转换成时间戳?数据很多,一条好转换,可是那么多怎么办?


回复讨论(解决方案)

select unix_timestamp('2011-4-19 12:00:00');
Copy after login
Copy after login

select unix_timestamp('2011-4-19 12:00:00');
Copy after login
Copy after login

我数据库不是时间戳形式,而是datetime形式

我数据库不是时间戳形式,而是datetime形式
你不是说要转成时间戳吗?unix_timestamp可以将你的datetime格式转换成时间戳啊 


我数据库不是时间戳形式,而是datetime形式
你不是说要转成时间戳吗?unix_timestamp可以将你的datetime格式转换成时间戳啊 
数据库里不是一条数据,那么多数据怎么转

数据库里不是一条数据,那么多数据怎么转
select unix_timestamp(time字段);time字段是数据库中你要转换的时间字段 他会全部都转的

直接比较就行了,可以不用转

select * from table1 where create_time>'2014-03-21 00:00:00'

查询可以直接比较
例如:select * from table where  createtime>='2014-01-01 00:00:00' and creattime
如果要批量显示可以这样
select *,  unix_timestamp(createtime) as createtime from table;

select * from table where createtime>='2014-01-01 00:00:00' and creattime

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 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!