Answer the question
In order to leave comments, you need to log in
How to make time intervals condition Smarty or PHP?
The question of such a plan, you need to display the text depending on the time intervals.
Ideally, of course, on smart, well, or on php I
went first by the template engine
Intervals
{$time_start_1 = '0:00'}
{$time_finish_1 = '9:59'}
{$time_start_2 = '10:00'}
{$time_finish_2 = '11:59'}
{$time_start_3 = '12:00'}
{$time_finish_3 = '13:59'}
{$time_start_4 = '14:00'}
{$time_finish_4 = '16:29'}
{$time_start_5 = '16:30'}
{$time_finish_5 = '23:59'}
{if $smarty.now|date_format:"%H:%M" >= $time_start_1 && $smarty.now|date_format:"%H:%M" <= $time_finish_1}
{$day_pvz = 'сегодня'}
{$time_pvz = 'до 12:00'}
{elseif $smarty.now|date_format:"%H:%M" >= $time_start_2 && $smarty.now|date_format:"%H:%M" <= $time_finish_2}
{$day_pvz = 'сегодня'}
{$time_pvz = 'до 14:00'}
{elseif $smarty.now|date_format:"%H:%M" >= $time_start_3 && $smarty.now|date_format:"%H:%M" <= $time_finish_3}
{$day_pvz = 'сегодня'}
{$time_pvz = 'до 16:30'}
{elseif $smarty.now|date_format:"%H:%M" >= $time_start_4 && $smarty.now|date_format:"%H:%M" <= $time_finish_4}
{$day_pvz = 'сегодня'}
{$time_pvz = 'до 18:00'}
{elseif $smarty.now|date_format:"%H:%M" >= $time_start_5 && $smarty.now|date_format:"%H:%M" <= $time_finish_5}
{$day_pvz = 'завтра'}
{$time_pvz = 'до 12:00'}
{/if}
Answer the question
In order to leave comments, you need to log in
<?php
var_dump('22:30' >= '0:00' && '22:30' <= '9:59');
var_dump('22:30' >= '00:00' && '22:30' <= '09:59');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question