Yesterday I created a small script with the current Twig version and noticed that when I use the date() filter Twig outputs the wrong date/time. See this example:
$template = $twig->loadTemplate("{{ dt|date('Y-m-d H:i:s') }}\n");
$dt = new DateTime();
print $dt->format("Y-m-d H:i:s\n");
$ts = $dt->format("U");
print strftime("%Y-%m-%d %H:%M:%S\n");
print $template->render(array("dt"=>$ts));
The output of this snippet is:
2010-12-15 13:23:56
2010-12-15 13:23:56
2010-12-15 12:23:56
Notice that DateTime::format() and strftime() show the correct time whereas the template shows the time minus one hour.
Yesterday I created a small script with the current Twig version and noticed that when I use the date() filter Twig outputs the wrong date/time. See this example:
$template = $twig->loadTemplate("{{ dt|date('Y-m-d H:i:s') }}\n");
$dt = new DateTime();
print $dt->format("Y-m-d H:i:s\n");
$ts = $dt->format("U");
print strftime("%Y-%m-%d %H:%M:%S\n");
print $template->render(array("dt"=>$ts));
The output of this snippet is:
2010-12-15 13:23:56
2010-12-15 13:23:56
2010-12-15 12:23:56
Notice that DateTime::format() and strftime() show the correct time whereas the template shows the time minus one hour.