i can’t really get it how to work with datetime-objects in symfony2.
i have few games-entries in database which one has a datetime-property.
and now i want to compare to the actual date: i want to have all records from the past 10 days. how can i achieve this?
i tried this
date($game->getZeit(), mktime(0,0,0,date('m'),date('d'),date('y')))
to get a compareable date which i can compare with
date('Y.m.d H:i:s', mktime(0,0,0,date('m'),date('d'),date('y')));
but that didnt work because
$game->getZeit()
cannot be converted to a string. why? so how can i debug this one? how can i know its value? how can i compare it with other datetimes or date-strings?
quick help would be really appreciated! 🙂
kind regards
In Symfony2 (Doctrine ORM) dates represented as DateTime objects (http://php.net/DateTime)
So if
$game->getZeit()is instance of DateTime, you can convert it to string like