Link: How to create DateTime object from string in symfony2/php
I am taking date from a form and passing all that data via a form.serialize() method with ajax. On the Symfony side, I am getting that value in string format. Now when I try to insert that data into database it was giving me an error as the type of that field was given date. So thanks to @briosheje I solved that thing.
But what if Now, sometimes I get null value from the form for that date value? Any idea, Anyone? Ohh, btw right now I have used if($dateValue != null OR $dateValue != '') condition.. any better solution then if() condition?