开发者

Mysql interprets 00:00:00 as 12:00am?

开发者 https://www.devze.com 2023-02-18 02:17 出处:网络
So mysql has atime(type) in which it has a 24 hour clock stored that can ouput time in am/pm formatwith the mysql function date_format(). The only problem is that when the user doesnt select the time,

So mysql has a time(type) in which it has a 24 hour clock stored that can ouput time in am/pm format with the mysql function date_format(). The only problem is that when the user doesnt select the time, the value that stores in the mysql database is 00:00:00 which turns out to be 12:00am when i echo it with php. So how would i frame it so it can tell a difference between a null value and 00:00:00 which is 12:00am? (Btw, i try inserti开发者_如何学Pythonng null into the time column, turns out to be 00:00:00, which is 12:00am).


So how would i frame it so it can tell a difference between a null value and 00:00:00 which is 12:00am? (Btw, i try inserting null into the time column, turns out to be 00:00:00, which is 12:00am).

Make the column nullable. (Remove the NOT NULL constraint.)


Its far better to validate the user input field by keeping select time field as a mandatory one.

Thanks

0

精彩评论

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

关注公众号