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
Get three days later
{{ "+3 day"|date('Y-m-d') }} //2014-03-09
//或者
date('+3days') //2014-03-09
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 can be used:
{{ var is empty ? "" : var|date("Y-m-d") }}
Set time zone
{{ var|date("Y-m-d", "Europe/Paris") }} //设置时区为欧洲巴黎
{{ var|date("Y-m-d", false) }} //设置当前时区
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: {...
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn