Le 13 mai 2011 14:29, Sylvain > Com-Océan <sylvain.comoc...@gmail.com> a écrit :
> 2011/5/13 Christophe COEVOET <s...@notk.org> > >> Le 13/05/2011 12:25, Sylvain > Com-Océan a écrit : >> >> Hi, >> >> I have a date field for an object (a doctrine entity) which can be empty. >> >> When I display this field with a date filter on an empty date, I got >> 11/30/-0001 >> {{ project.deadline|date("m/d/Y") }} >> # display : 11/30/-0001 >> >> Maybe this can be fix in Twig (?). >> >> But even it is normal, how can I test if date value is empty or null with >> twig ? >> >> I test the following code but it change nothing : >> {% if project.deadline %} >> {{ project.deadline|date("m/d/Y") }} >> {% endif %} >> >> Thanks a lot ! >> >> I have other questions about Symfony2 on the forum : >> Question about UserBundle and Doctrine2 >> ORM<http://forum.symfony-project.org/viewtopic.php?f=23&t=35274> >> Question about >> doctrine:generate:entities<http://forum.symfony-project.org/viewtopic.php?f=23&t=35273> >> Best practice for filter >> form<http://forum.symfony-project.org/viewtopic.php?f=23&t=35179> >> >> Use* {% if project.deadline is defined %}* >> >> -- >> Christophe | Stof >> >> -- >> If you want to report a vulnerability issue on symfony, please send it to >> security at symfony-project.com >> >> You received this message because you are subscribed to the Google >> Groups "symfony users" group. >> To post to this group, send email to symfony-users@googlegroups.com >> To unsubscribe from this group, send email to >> symfony-users+unsubscr...@googlegroups.com >> For more options, visit this group at >> http://groups.google.com/group/symfony-users?hl=en >> > > Thanks for your answer but it still display the date : 11/30/-0001 (empty > date return by doctrine filtered with 'date' twig filter) > > In fact, this pamameters is defined but it is an empty date returned by > doctrine. > > I don't know how to test an empty date return by doctrine2. > > > -- > Sylvain PAPET > Développeur Web > Agence de communication Com-Océan > www.com-ocean.com > FYI: A var_dump on this field (populate by doctrine2 from a mysql record having empty date : '0000-00-00 00:00' return : *object*(*DateTime*)[*1929*] *public* 'date' => string '-0001-11-30 00:00:00' *(length=20)* *public* 'timezone_type' => int 3 *public* 'timezone' => string 'Europe/Paris' *(length=12)* -- Sylvain PAPET Développeur Web Agence de communication Com-Océan www.com-ocean.com -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en