mysql日期类操作
1、date
2、datetime
3、函数
NOW(): 当前时间,格式为 YYYYMMDD HHIISS 2013-03-06 16:58:22 FROM_UNIXTIME(timestamp): 将时间戳专为格式化的日期格式同上 DATE_FORMAT('2013-03-06 19:23:24','%Y-%m-%d %H:%i:%s'): 显示地将日期格式化,参数SQL:
update `demo` set day=SUBDATE(day,INTERVAL 2 DAY),daytime=UNIX_TIMESTAMP(SUBDATE(day,INTERVAL 2 DAY)) where userid=1;
update `demo` set day=SUBDATE(NOW(),INTERVAL 2 DAY),daytime=UNIX_TIMESTAMP(DATE_FORMAT(SUBDATE(NOW(),INTERVAL 2 DAY),'%Y-%m-%d')),logtime=SUBTIME(NOW(),'2 0:0:0') where userid=1;UNIX_TIMESTAMP(DATE_FORMAT(SUBDATE(NOW(),INTERVAL 2 DAY) : 取得两天前的日期起始时间戳。