mysql的时间转换问题

日期转换为UNIX时间戳用函数UNIX_TIMESTAMP()

UNIX时间戳转换为日期用函数: FROM_UNIXTIME()

select FROM_UNIXTIME(1156219870);

日期转换为UNIX时间戳用函数: UNIX_TIMESTAMP()

Select UNIX_TIMESTAMP(’2006-11-04 12:23:00′);

例:mysql查询当天的记录数:

$sql=”select * from message Where DATE_FORMAT(FROM_UNIXTIME(chattime),’%Y-%m-%d’) = DATE_FORMAT(NOW(),’%Y-%m-%d’) order by id desc”;

当然大家也可以选择在PHP中进行转换UNIX时间戳转换为日期用函数: date()

date('Y-m-d H:i:s', 1156219870);

日期转换为UNIX时间戳用函数:strtotime()

strtotime('2010-03-24 08:15:42');

实例:

/*

周五 0点至12点 注册医生信息(id,姓名、医院、科室、职称)

*/

select unix_timestamp('2011-09-02 00:00:00'),unix_timestamp('2011-09-02 12:00:00');

select us.uid as 'ID',us.username as '用户名',usf.workunit as '所在医院',usf.jobtitle as '职称',usf.kee as '一级科室',usf.keee as '二级科室',usf.keeee as '三级科室' from uchome_space us,uchome_spacefield usf where us.uid=usf.uid 

and dateline between unix_timestamp('2011-09-02 00:00:00') and unix_timestamp('2011-09-02 12:00:00') and workunit !='' order by dateline desc;

转载于:https://www.cnblogs.com/nonoweipan/archive/2011/09/05/2168107.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值