szwagier
szwagier

Reputation: 27

Smarty check if date is between

i need check if smarty now date is equal or between my two dates. If dates is the same months its work. But if: Start = 19.01.2015 and

Stop = 1.02.2015 and 

smarty now is 19.01.2015 it show no. Only if i change months it don't work

{if ($smarty.now|date_format:"%d.%m.%Y") >= ($value->getVariableValue('Start')) AND ($smarty.now|date_format:"%d.%m.%Y") <= ($value->getVariableValue('Stop'))}
yes
{else}
no
{/if}

Upvotes: 1

Views: 2962

Answers (1)

Roh&#236;t J&#237;ndal
Roh&#236;t J&#237;ndal

Reputation: 27222

try this i hope it will work :

Php file :

<?php

$start_date = "19.01.2015";
$end_date = "1.02.2015";

  $smarty->assign('start', $start_date); 
$smarty->assign('stop', $end_date); 
 $smarty->display("date.tpl");

?>

tpl file(date.tpl) :

<{if (($smarty.now|date_format:"%d.%m.%Y") >= ($start)) AND (($smarty.now|date_format:"%d.%m.%Y") <= ($stop)) }>
yes
{else}
no
{/if}

Upvotes: 2

Related Questions