【原】MySQL时间戳timestamp比较
DROP TABLE IF EXISTS `t`; CREATE TABLE `t` ( `id` int(11) NOT NULL AUTO_INCREMENT, `ts` timestamp , PRIMARY KEY (`id`) ) ; INSERT INTO `t` VALUES ('1', '2014-01-06 17:01:36');
-- DELETE FROM t WHERE ts < UNIX_TIMESTAMP(CONCAT(DATE_SUB(DATE(NOW()),INTERVAL -3 MONTH ),' ',CURTIME())) SELECT ts, UNIX_TIMESTAMP(ts) < UNIX_TIMESTAMP ( CONCAT( DATE_SUB(DATE(NOW()), INTERVAL 3 MONTH), ' ', CURTIME() ) ), ( CONCAT( DATE_SUB( DATE(NOW()), INTERVAL 3 MONTH ), ' ', CURTIME() ) ), UNIX_TIMESTAMP(ts) < UNIX_TIMESTAMP ( CONCAT( DATE_SUB(DATE(NOW()), INTERVAL 1 MONTH), ' ', CURTIME() ) ), ( CONCAT( DATE_SUB( DATE(NOW()), INTERVAL 1 MONTH ), ' ', CURTIME() ) ) FROM t
php 相关代码
date('Y-m-d H:i:s', strtotime('-3 month'));
posted on 2014-03-06 17:21 longhua828 阅读(4202) 评论(0) 编辑 收藏 举报