简体   繁体   中英

if input maybe undefined how to use swig date filter

I use swig in my nodejs project,when use date filter,I found this:

{{t.updateAt|date('Y-m-d H:i:s',-480)}}
NaN-NaN-NaN NaN:NaN:NaN

because sometimes t.updateAt is undefined, when this time I need date filter output ''.

so, How can I do?

{% if t.updateAt %}
    {{t.updateAt|date('Y-m-d H:i:s',-480)}}
{% endif %}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM