Answer the question
In order to leave comments, you need to log in
How to store date by default in MySQL or why DateTime('0000-00-00') shows nonsense?
Hello!
The question is very philosophical. Base, table, the table has optional date fields.
For convenience, I made them default-values (0000-00-00), so that in PHP both filled and unfilled fields are treated equally (display zeros or real dates).
What was my surprise when, as a result of executing this code
$date = new DateTime('0000-00-00');
echo $date->format("Y-m-d");
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question