w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
TWIG date filter Pacific Standard Time


{# using "PST" is fine too as I noticed #}
{{ post.published_at|date("F jS \a\t g:ia", "America/Los_Angeles") }}

The timezone parameter uses the accepted values from PHP. Los Angeles should be PST so it should work. See the list of supported timezones.

It's also shown in the twig documentation (or at least there's a hint) where they use Europe/Paris as timezone.


Example to change an existing date, assuming you have a DateTime object.


$date = new DateTime('2013-12-08 21:20:46');
$pst  = new DateTimeZone('PST');

And in twig:

{{ date|date("F jS \a\t g:ia", "PST") }}

Will output December 8th at 12:20pm

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.