在MYSQL中插入當(dāng)前時(shí)間:
NOW()函數(shù)以`'YYYY-MM-DD HH:MM:SS'返回當(dāng)前的日期時(shí)間,可以直接存到DATETIME字段中。
CURDATE()以’YYYY-MM-DD’的格式返回今天的日期,可以直接存到DATE字段中。
例:insert into tablename (fieldname) values (now())
now():以'yyyy-mm-dd hh:mm:ss'返回當(dāng)前的日期時(shí)間,可以直接存到datetime字段中。
curdate():’yyyy-mm-dd’的格式返回今天的日期,可以直接存到date字段中。
//獲取Mysql系統(tǒng)時(shí)間
select now() as systime ;
select sysdate() as systime ;
select current_date as systime ;
select current_time as systime ;
select current_timestamp as systime ;
自己寫的例子,為了以后忘記了查詢用:select * from abing where to_days(sysdate())=to_days(createtime);
select * from abing where to_days(sysdate())=to_days(createtime);
select * from abing where str_to_date(now(),'%Y-%m-%d')=str_to_date(createtime,'%Y-%m-%d');
use abin;
create table abin1(
id integer not null auto_increment,
name varchar(100),
create_time datetime ,
update_time datetime ,
constraint pk_abin1 primary key(id));
insert into abin1(name,create_time,update_time) values ('abin1',now(),now());
insert into abin1(name,create_time,update_time) values ('abin1',sysdate(),sysdate());