【问题标题】:SMARTY - how to add days in variable to date?SMARTY - 如何在变量中添加天数?
【发布时间】:2018-04-02 03:45:43
【问题描述】:

我想添加到 $order->date_add 这是日期,额外的天数。天数在变量 $order->days 中 我有这样的代码

{$order->date_add|cat:' +60 days'|date_format:"%d-%m-%Y"}

但我想用变量 $order->days 替换数字“60”。不幸的是,我不能在 php 中做到这一点 - 我必须在 smarty 中做到这一点。可能吗?如何用变量替换那个 60?

【问题讨论】:

    标签: smarty smarty3 smarty2


    【解决方案1】:

    您在 {$ order-> date_add} 中有什么格式的日期?

    如果有时间戳,可以这样做:

    {$order->date_add+20*24*60*60|date_format:"%d-%m-%Y"} //+20 days
    

    {$order->date_add + $order->days|date_format:"%d-%m-%Y"} // + {$order->days} days
    

    【讨论】:

      猜你喜欢
      • 2011-06-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-21
      • 2011-01-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多