3
I have a column in the type database date
.
When I change some date in a form php
and leave blank the same instead of being blank she brings me this date of 1900-01-01
.
Below the input I use to change the date.
Date Departure:
<input type="date" id="saida" name="saida" value="<?php echo $datasaida; ?>"/>
I believe it is the problem in the bank. Any idea?
Friend that if you set the field in the database with some type that corresponds to a date and you do not send a valid date, it will bring the default, which is not something null or white, in Mysql if you do what you are doing it will bring 1969-01-01
– Duque
I get it, there’s no way to fix this ?
– KevinF
Patching is never the best option, the right one and fix. You can set the field to NULL. NULL is different from empty, you will have to treat this in PHP and tell SQL that you want to leave the field worthless.
– Renato Tavares
I’ve adjusted, and also in mine
get
I made a conditionif
when the date is 01-01-1970 it shows nothing if it does not show the date.– KevinF
You can set the field to a default value, that is, when you do not save anything to it, the field will take the default value, is the best option for you, instead of comparing strings.
– Duque
Right, but I don’t even want a value I want to be left with nothing. Want by this answer set a default value put for me to see if it is viable.
– KevinF
Hello Kevin! Could you edit the question with the table creation script? Make sure the column is set to accept null..
– Jhonatas Kleinkauff