Detailed date usage of twig in symfony2.4

Source: Internet
Author: User
Tags set time
In this paper, we mainly introduce the date usage in the twig of symfony2.4, and analyze the common methods for date and time operation in Twig with the example form. Need friends can refer to, hope to help you.

Get current time:

{"Now" |date ("Y-m-d")}}//2014-03-06

Get three days after the time

{{"+3 Day" |date (' y-m-d ')}}//2014-03-09//or date (' +3days ')//2014-03-09

To handle the variables in the twig:

{{var|date ("y-m-d")}}//2014-03-06

Date_modify usage:

{{var|date_modify ("+1 Day") |date ("Y-m-d")}}//2014-03-07

If the var variable is empty and the default value is set, the following syntax is available:

{{var is empty?} "": Var|date ("y-m-d")}}

Setting the time zone

{{var|date ("y-m-d", "Europe/paris")}}//Set time zone for Europe Paris {{var|date ("y-m-d", False)}}//Set current time zone

Related recommendations:

Detailed description of Symfony2 controller usage

Detailed system routing for Symfony2

Detailed Symfony2 plug-in format

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.