2013-12-21 298 views
0

我正在創建smarty3代碼,顯示產品的預期交貨日期,具體取決於當前時間和星期幾。Smarty - 日期範圍

Tuesday -> <14:00 Friday - 14:00 Monday) 
Wednesday -> <14:00 Monday - 14:00 Tuesday) 
Thursday -> <14:00 Tuesday - 14:00 Wednesday) 
Friday -> <14:00 Wednesday - 14:00 Thursday) 
Monday -> <14:00 Thursday - 14:00 Friday) 

我正在考慮將列表存儲在數組中,其中鍵是星期幾,值是範圍。

如何檢查當前服務器日期是否與任何範圍對應,以及如何將範圍存儲在數組中以便我可以檢查範圍?

+0

不應在最後一排開始星期一? –

+0

你說得對,我已經修好了桌子。仍然不知道如何存儲範圍你:) –

回答

0

在PHP中:

$expected = time()-14*3600+2*86400; 
if(date('w',$expected) ==6){ 
    $expected+=86400; 
} 
if(date('w',$expected) ==0){ 
    $expected+=86400; 
} 
print date('l',$expected); 

在智者:

{$expected = $smarty.now() -14*3600+2*86400} 
{if date('w',$expected) ==6} 
    {$expected = $expected + 86400} 
{/if} 
{if date('w',$expected) ==0} 
    $expected+=86400; 
    {$expected = $expected + 86400} 
{/if} 
{$expected|date_format:%A}