: This article mainly introduces the analysis of date usage in twig of symfony24. For more information about PHP tutorials, see. This example describes the date usage in twig of symfony2.4. We will share this with you for your reference. The details are as follows:
Obtain the current time:
{"Now" | date ("Y-m-d")} // 2014-03-06
Get three days later
{"+ 3 day" | date ('Y-m-D')} // 2014-03-09 // or date ('+ 3days ') //
Process variables in 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 ")}}
Set time zone
{Var | date ("Y-m-d", "Europe/Paris ")}} // Set the time zone to Paris, Europe {var | date ("Y-m-d", false)} // set the current time zone
I hope this article will help you design PHP programs based on the Symfony framework.
The preceding section describes the date usage analysis in twig of symfony24, including some content, and hopes to help those who are interested in PHP tutorials.