i have a little problem and I really don't know why. I am printing a datetime variable in twig with |date() but it is allways printing the actual time.
for Debugging I put the following Code in my Template:
<pre>
{% debug entity.getCreatedAt|date("d.m.Y H:i:s") %}
{% debug entity.getCreatedAt|raw %}
{% debug entity.CreatedAt|raw %}
{% debug entity.CreatedAt|date("d.m.Y H:i:s") %}
My Variable is called CreatedAt so normally I should get the correct output with entity.CreatedAt|date("d.m.Y H:i:s"), right?
My Debug output is as follows:
string '16.01.2013 13:46:03' (length=19) //entity.getCreatedAt|date("d.m.Y H:i:s")
object(DateTime)[4611] //entity.getCreatedAt|raw
public 'date' => string '2013-01-16 13:46:03' (length=19)
public 'timezone_type' => int 3
public 'timezone' => string 'Europe/Berlin' (length=13)
object(DateTime)[4938] //entity.CreatedAt|raw
public 'date' => string '2013-02-20 21:46:53' (length=19)
public 'timezone_type' => int 3
public 'timezone' => string 'Europe/Berlin' (length=13)
string '20.02.2013 21:46:53' (length=19) //entity.CreatedAt|date("d.m.Y H:i:s")
I don't understand why it is NULL as soon as I call CreatedAt. And OUTSIDE of the debug tag it is ALLWAYS NULL, not depending on the writing.
In my Entity I've got:
private $CreatedAt;
public function setCreatedAt($createdAt)
{
$this->CreatedAt = $createdAt;
return $this;
}
public function getCreatedAt()
{
return $this->CreatedAt;
}
And in the YML I've got:
CreatedAt:
type: datetime
nullable: true
Does anybody see a mistake?? I really don't find it, maybe it is a bug?
Thanks