Skip to content

date() filter not showing correct date/time #207

@dennisjac

Description

@dennisjac

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions