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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With