[英]Add 1 month to fixed date in Smarty 2.x & show days left to that date in WHMCS
[英]add days to date smarty
我想將我商店中某件商品的運輸時間添加到當前日期。 這樣我就可以得到一個可用日期。
我必須用 smarty 編程整個事情。
我試過這個但它不起作用:
<g:availability_date>
{if $sArticle.shippingtime > 0}
Verfügbar ab:
{assign var="estimated_days" value=$smarty.now|date_format:"%a, %d %b %Y %T %Z"}
{"$estimated_days +$Article.shippingtime"|strtotime|date_format:"%a, %d %b %Y %T %Z"}
{/if}
</g:availability_date>
但是當我在當前日期上增加幾天時,我得到一個有效的 Output...
Verfügbar ab:
{assign var="estimated_days" value=$smarty.now|date_format:"%a, %d %b %Y %T %Z"}
{"$estimated_days +3 days"|strtotime|date_format:"%a, %d %b %Y %T %Z"}
{/if}
</g:availability_date>
有人可以幫我解決這個問題嗎?
最好的問候盧卡斯
這是$estimated_days + $Article.shippingtime
與$estimated_days + 3 days
。
那么$Article.shippingtime
是什么? 盡管該問題沒有任何 output,
你曾經添加一個絕對時間戳和一個相對偏移量。
可能您必須首先從絕對時間戳轉換為相對偏移量。
“我必須用 smarty 編程整個事情”對我來說聽起來毫無意義,
最常見的是向模板引擎提供計算值。
它甚至不是 controller 的職責,而是底層 model 的職責。
對於簡單的計算,在模板中仍然可以,而不是復雜的計算。
您只需要稍微調整您的 output 標記,PHP 不能在單引號內插入點符號。 在$Article.shippingtime
周圍添加大括號並在其后添加“天”。
{assign var="estimated_days" value=$smarty.now|date_format:"%a, %d %b %Y %T %Z"}
{"$estimated_days +{$Article.shippingtime} days"|strtotime|date_format:"%a, %d %b %Y %T %Z"}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.