I would like to display a formatted date in twig by applying a filter to a Unix timestamp. Is such a feature available in twig?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
There is a filter called
date
.In the following example
mydate
equals1286199900
:If you just divide it by 1000 there might be an error like
Failed to parse time string (1384361503.5) at position 7
I would add round function to it
{% set timestamp = (rating.ratingDate / 1000)|round(0, 'floor') %} {{timestamp|date('d. M Y')}}
I know I am playing an archaeologist but it might be helpful for someone.