Analysis of date usage in twig of symfony2.4, symfony2.4twig
The example in this article describes the usage of date in twig of symfony2.4. Share it with everyone for your reference, the details are as follows:
Get the current time:
{{ "now"|date("Y-m-d") }} //2014-03-06
Copy after login
Get three days later
{{ "+3 day"|date('Y-m-d') }} //2014-03-09
//或者
date('+3days') //2014-03-09
Copy after login
Process variables in twig:
{{ var|date("Y-m-d") }} //2014-03-06
Copy after login
date_modify usage:
{{ var|date_modify("+1 day")|date("Y-m-d") }} //2014-03-07
Copy after login
If the var variable is empty and the default value is set, the following syntax can be used:
{{ var is empty ? "" : var|date("Y-m-d") }}
Copy after login
Set time zone
{{ var|date("Y-m-d", "Europe/Paris") }} //设置时区为欧洲巴黎
{{ var|date("Y-m-d", false) }} //设置当前时区
Copy after login
I hope this article will be helpful to everyone’s PHP program design based on the Symfony framework.
Articles you may be interested in:
- Symfony2 joint query implementation method
- Detailed explanation of creating page instances in Symfony2
- Summary of session and cookie usage in Symfony2
- A summary of the method of obtaining data from the database in Symfony2
- Detailed explanation of form usage of Symfony2 framework study notes
- Analysis of plug-in format of Symfony2 study notes
- Symfony2 study notes Detailed explanation of system routing
- Detailed explanation of controller usage in Symfony2 study notes
- Detailed explanation of template usage in Symfony2 study notes
- Detailed explanation of installation of third-party Bundles instances in Symfony2
- Symfony2 Analysis of function usage examples
http://www.bkjia.com/PHPjc/1111904.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1111904.htmlTechArticleAnalysis of date usage in twig of symfony2.4, symfony2.4twig This article tells the example of date in twig of symfony2.4 usage. Share it with everyone for your reference, the details are as follows: Get the current time: {...