2017-09-25 2 views
-1

smarty를 사용하고 있습니다. 두 시간 값을 확인하고 싶습니다. 잘 작동하지 않습니다. 내가 한 일은 아래에 나와 있지만, 그것은 else 조건으로 들어 가지 않습니다.Smarty에서 두 시간 값을 comapre하는 방법

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

가능한 복제를 사용하여 [유식에서 두 날짜 비교 (https://stackoverflow.com/questions/27250242/compare-two-dates-in-smarty) – Stony

답변

0

시간을 아니오로 변환해야합니다. 한 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> 
} 
관련 문제