We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 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



8.1k

just write

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

or

{{ 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) }}
</p>

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


42.1k

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

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