Smarty - 日期范围

时间:2013-12-21 16:05:34

标签: arrays smarty

我正在创建smarty3代码,根据当前时间和星期几显示产品的预期交付日期。

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)

我正在考虑将列表存储在一个数组中,其中Key是星期几,value是范围。

如何检查当前服务器日期是否与任何范围相对应,以及如何将范围存储在数组中以便我可以检查范围?

1 个答案:

答案 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}