Knp\Bundle\TimeBundle\Templating\Helper\TimeHelper::getDatetimeObject PHP Method

getDatetimeObject() public method

Returns a DateTime instance for the given datetime
public getDatetimeObject ( mixed $datetime = null ) : DateTimeInterfac\DateTimeInterface
$datetime mixed
return DateTimeInterfac\DateTimeInterface
    public function getDatetimeObject($datetime = null)
    {
        if ($datetime instanceof DateTimeInterface) {
            return $datetime;
        }
        if (is_integer($datetime)) {
            $datetime = date('Y-m-d H:i:s', $datetime);
        }
        return new DateTime($datetime);
    }