Skip to content

02.08 Data formats

rafageist edited this page Nov 16, 2026 · 1 revision

2.8 Formatos de datos

Los formatos de datos son modificadores que requieren parámetros más allá de un solo símbolo.

6.8.1 Formato de fecha

Sintaxis

{/variable:php-format-date/}

Ejemplo

index.php

echo new div('index.tpl', ['today' => time()]);

index.tpl

Timestamp: {$today}
Today is: {/today:Y-m-d/}
Now is: {/today:h:i:s/}

Salida

Timestamp: 1341956900
Today is: 2012-07-10
Now is: 05:48:20

6.8.2 Formato de número

Sintaxis

{#variable:decimals separator thousands-separator#}

Ejemplo

index.php

echo new div('index.tpl', ['number' => 2900200.4567]);

index.tpl

The number: {$number}
The integer part: {#number:0#}
Two decimals: {#number:2#}
Two decimals and separators: {#number:2,.#}
Two decimals and other separators: {#number:2.'#}
More decimals and other separators: {#number:9|-#}

Salida

The number: 2900200.4567
The integer part: 2900200
Two decimals: 2900200.46
Two decimals and separators: 2.900.200,46
Two decimals and other separators: 2'900'200.46
More decimals and other separators: 2-900-200|456700000

Div

Enlaces

Clone this wiki locally