Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4259260
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T05:45:36+00:00 2026-05-21T05:45:36+00:00

I am using Twig and this date filter http://www.twig-project.org/doc/templates.html#date Apparently they are looking out

  • 0

I am using Twig and this date filter

http://www.twig-project.org/doc/templates.html#date

Apparently they are looking out for DateTime instances in the parameter.

looking at this http://www.php.net/manual/en/datetime.construct.php

I have trouble understanding the php datetime object and how to use the timezone.

Given that i know basic PHP and is familiar with simple web programming, how do I use it to display a date and time using the Twig date filter while catering for timezone?

If there is a simpler way to do it while using the date filter, but NOT using datetime object, i would be open to it.

I am only concerned that the solution works, rather than the “correctness” or “elegance” of the solution.

  • 1 1 Answer
  • 3 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T05:45:37+00:00Added an answer on May 21, 2026 at 5:45 am

    I think you might have misread the documentation.

    The date filter accepts any date format supported by DateTime and DateTime instances.

    That means that you can just pass in things like “2011-01-20 12:00:00” OR a real DateTime Object.

    But you don’t have to deal with the object if you don’t want do.

    Now if you need that string to be displayed in a specifiy timezone I would set that timezone in php before passing it to twig

    $x = new DateTime("2010-01-01 12:00:00");
    $x->setTimezone(new DateTimeZone("The Timezone you need"));
    // pass to twig
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

using this http://bl.ocks.org/950642 we can see how to add images to nodes, the question
I am using the SensioFrameworkExtraBundle located here http://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/index.html to allow for routes and template
Using symfony2 with twig templates, I normally use js embedded inside the *html.twig file
Im using Twig for template in my website, I extend layout.html.twig in all my
I am developing an application using symfony2 and twig for templates. The problem comes
I'm using Perl's XML::Twig module to transform XML into (X)HTML. I need to output
I am using the following template to extend specific widget {% use 'SonataAdminBundle:Form:form_admin_fields.html.twig' %}
In my Google App Engine project, I'm currently using Twig for accessing the Datastore
I am using Twig to conditionally display a piece of HTML (or trying to,
I am having issues using twig templates for email in SF2. First, I created

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.