插入到mysql数据库中的日期和时间,为何时间部分显示全部为0。
例如:2010-09-28 00:00:00
在程序中后台打印时显示2010-09-28 18:28:15.468
我现在是想得到日期和时间,可是时间部分不能显示。
后台和数据库用的都是timestamp类型,不存在类型不一致的问题。
例如:2010-09-28 00:00:00
在程序中后台打印时显示2010-09-28 18:28:15.468
我现在是想得到日期和时间,可是时间部分不能显示。
后台和数据库用的都是timestamp类型,不存在类型不一致的问题。
use test;drop table if exists time_stamp;create table if not exists time_stamp(nowTime timestamp);insert into time_stamp values(now());
insert into time_stamp values(current_timestamp);
insert into time_stamp values('2010-09-30 12:25:30');
像这样使用timestamp类型记录时间,查询结果如下:
mysql> select * from time_stamp;
+---------------------+
| nowTime |
+---------------------+
| 2010-09-29 11:04:54 |
| 2010-09-29 11:04:54 |
| 2010-09-30 12:25:30 |
+---------------------+
3 rows in set (0.00 sec)没有像lz所说的时间都为0的情况啊。
估计是lz的后台程序的变量类型有问题。