Set Html Datepicker To Null
I have a form on a php page that submits information about events. Information submitted is stored in a MySQL database. When a user does not select a date from the date picker, 000
Solution 1:
How about having an additional PHP statement before you do your SQL transaction that checks specifically for that value and var type and then setting it to null if it matches those conditions?
if ($date && $date === '0000-00-00') {
$date = null;
}
Alternatively, there's an inbuilt date_parse function
$date = '0000-00-00';
$parse_date = date_parse($date);
if ($parse_date['error_count'] > 0) {
$date = null;
}
However, there's also a DB side solution where you can change the column to not accept 0000-00-00 as a date. See http://dev.mysql.com/doc/refman/5.1/en/sql-mode.html#sqlmode_no_zero_date
Post a Comment for "Set Html Datepicker To Null"