开发者

php sends normal time but mysql inserts 00:00:08 into table which is wrong

date('H-m-s') gives something like this when I echo variable > 08-07-16

I have table in mysql and the field type is set to TIME.

And when I transfer this data there, in mysql table I see this > 00:00:08

I开发者_C百科 repeat it several times but I see only this > 00:00:08

What's the problem with mysql ???


'm' is month, you want 'i'

see http://uk.php.net/date

and you should use date('H:i:s') instead of the - this is no valid time format.

you could also use TIME(NOW()) directly in SQL


MySQL's TIME type expects the time in the format HH:MM:SS. Generate your date in PHP as:

date("H:i:s");

Or as eykanal points out, use the DATETIME type instead.


TIME is not equivalent to DATE. Set the field appropriately and it should work.

You should also read up on appropriate ways to send time and date data to mysql, as php and mysql deal with time and dates differently.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜