Reputation: 2807
I need to convert a date to a UNIX timestamp in a Twig template:
<li>{{ user.expired }}</li>
Is there a function in Twig to do it?
Upvotes: 20
Views: 32712
Reputation: 8915
There is the built-in date
filter in Twig. You can pass any strtotime
-compatible argument.
<li>{{ user.expired | date('U') }}</li>
U
is the pattern that will display the unix timestamp.
Upvotes: 68