2017-09-25 70 views
-1

我正在使用smarty。我想檢查兩個時間值。它運作不好。我所做的是如下所示,但它沒有進入其他條件。如何comapre Smarty中的兩個時間值

eg: 
    stime = 10:30 
    nowtime = current time(00:00 format) 
{ if stime < nowtime} 
    <li id="rv{$idx+1}" style ="display:none">test</li> 
    {else} 
    <li id="rv{$idx+1}" style ="display:block">test2</li> 
    {/if} 
+1

的可能的複製[在smarty的比較兩個日期](https://stackoverflow.com/questions/27250242/compare-two-dates-in-smarty) – Stony

回答

0

你必須將你的時間轉換爲no。使用的strtotime()函數

$stime = strtotime("12:30"); 
$endtime = strtotime("11:30"); 

if($stime < $endtime){ 
    //Your logic goes here 
    //<li id="rv{$idx+1}" style ="display:none">test</li> 
}else{ 
    //Your logic goes here 
    //<li id="rv{$idx+1}" style ="display:block">test2</li> 
} 
相關問題