We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Format date

Hi all How to format date in volt, this is my code {{ date('d-m-Y',date)}}, run error : A non well formed numeric value encountered in

If i use php <?php print_r (date("d-m-Y",strtotime($date)));?> very gool, i doesn't see strotime in volt


just write

{{ date("d-m-Y") }}


{{ date("d-m-Y", time()) }}

If you want print custom time from variable, this variable must be integer type of Unix timestamp. Example

{% set today = time() %}
<p>Today is: 
{{ date("d-m-Y", today) }}

{% set tomorrow = time()+86400 %}
<p>Tomorrow is: 
{{ date("d-m-Y", tomorrow) }}


Register the strtotime function as shown in the documentation http://docs.phalcon.io/en/latest/reference/volt.html#id3 Then you can use

{{ date('d-m-Y', strtotime(date)) }}