Discussion:
Object of class DateTime could not be converted to string
Marcello Voc
2012-03-05 17:42:29 UTC
Permalink
hi guys
i try to print a data from database( type field datatime)

echo $product->getExpiry();

but return this error

Object of class DateTime could not be converted to string



i have try to force convert in entity with methos __toString but not
work

public function __toString()
{
return (string) $this->expiry;
}
Mario Alberto Alvarez Garcia
2012-03-05 18:33:41 UTC
Permalink
try this: echo $product->getExpiry()->format('Y-m-d');
Post by Marcello Voc
hi guys
i try to print a data from database( type field datatime)
echo $product->getExpiry();
but return this error
Object of class DateTime could not be converted to string
i have try to force convert in entity with methos __toString but not
work
public function __toString()
{
return (string) $this->expiry;
}
--
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 "Symfony2" group.
To post to this group, send email to symfony2-/***@public.gmane.org
To unsubscribe from this group, send email to
symfony2+unsubscribe-/***@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
sugee
2012-03-30 13:31:47 UTC
Permalink
That worked
Thanks

suku

On Mar 5, 11:33 pm, Mario Alberto Alvarez Garcia
Post by Mario Alberto Alvarez Garcia
try this: echo $product->getExpiry()->format('Y-m-d');
Post by Marcello Voc
hi guys
i try to print a data from database( type field datatime)
echo $product->getExpiry();
but return this error
Object of class DateTime could not be converted to string
i have try to force convert in entity with methos __toString but not
work
public function __toString()
    {
        return (string) $this->expiry;
    }
--
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 "Symfony2" group.
To post to this group, send email to symfony2-/***@public.gmane.org
To unsubscribe from this group, send email to
symfony2+unsubscribe-/***@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
Continue reading on narkive:
Loading...