osm-commerces/templates/admin/_labourage_time_ago.html.twig
2025-07-15 23:23:32 +02:00

16 lines
No EOL
586 B
Twig

{# Template partiel pour afficher une date et le temps écoulé #}
{% set now = "now"|date('U') %}
{% set then = date|date('U') %}
{% set diff = now - then %}
{% set hours = (diff / 3600)|round(0, 'floor') %}
{% set days = (diff / 86400)|round(0, 'floor') %}
<span title="{{ date|date('d/m/Y H:i') }}">
{{ date|date('d/m/Y H:i') }}
{%- if days > 0 -%}
(il y a {{ days }} jour{{ days > 1 ? 's' : '' }})
{%- elseif hours > 0 -%}
(il y a {{ hours }} heure{{ hours > 1 ? 's' : '' }})
{%- else -%}
(il y a moins d'une heure)
{%- endif -%}
</span>