Код: Выделить всё
$date = explode(':',$model->time_out);
$date=$date['0']*3600+$date['1']*60+$date['2'];
$creteria->addCondition('date_end-date_create<='.($date+6*3600).'');
Код: Выделить всё
$date = explode(':',$model->time_out);
$date=$date['0']*3600+$date['1']*60+$date['2'];
$creteria->addCondition('date_end-date_create<='.($date+6*3600).'');
Код: Выделить всё
TIMESTAMPDIFF(SECOND, date_create, date_end)
В базе у меня время храниться как надо, в формате time(), а вот с формы приходит читабельное такое как 23:12:01, и его надо конвертировать в time() для того чтоб сделать праверкуSiZE писал(а):Код: Выделить всё
TIMESTAMPDIFF(SECOND, date_create, date_end)
так не работает я пробывалlancecoder писал(а):strtotime
ну тогдаBarssoft писал(а):В базе у меня время храниться как надо time()
Returns the Unix timestamp corresponding to the arguments given. This timestamp is a long integer containing the number of seconds between the Unix Epoch (January 1 1970 00:00:00 GMT) and the time specified.
int mktime ([ int $hour = date("H") [, int $minute = date("i") [, int $second = date("s") [, int $month = date("n") [, int $day = date("j") [, int $year = date("Y") [, int $is_dst = -1 ]]]]]]] )
Код: Выделить всё
$date = mktime( $date['0'], $date['1'], $date['2'] );
SiZE писал(а):ну тогдаBarssoft писал(а):В базе у меня время храниться как надо time()
Returns the Unix timestamp corresponding to the arguments given. This timestamp is a long integer containing the number of seconds between the Unix Epoch (January 1 1970 00:00:00 GMT) and the time specified.
int mktime ([ int $hour = date("H") [, int $minute = date("i") [, int $second = date("s") [, int $month = date("n") [, int $day = date("j") [, int $year = date("Y") [, int $is_dst = -1 ]]]]]]] )Регулярку проверки формата времени не забыл?Код: Выделить всё
$date = mktime( $date['0'], $date['1'], $date['2'] );
Код: Выделить всё
if($model->time_out!=null and $model->status==2){
$date = explode(':',$model->time_out);
$date=mktime($date['0'],$date['1'],$date['2']);
$tecdate = date('d-m-Y');
$tecdate=strtotime($tecdate);
$date =$date-$tecdate;
//$date=strtotime($model->time_out);
$creteria->addCondition('date_end-date_create<='.($date).'');
Ты отжог конкретноBarssoft писал(а):Сделал так незнаю паравильно ли этоКод: Выделить всё
$tecdate = date('d-m-Y'); $tecdate=strtotime($tecdate); $date =$date-$tecdate; $creteria->addCondition('date_end-date_create<='.($date).'');
Мне нужно сделать выборку всех записей где время окончания минус время начала меньше или равно заданому с формы в формате 01:02:03 часы, минуты, секундыSiZE писал(а):Ты отжог конкретноBarssoft писал(а):Сделал так незнаю паравильно ли этоКод: Выделить всё
$tecdate = date('d-m-Y'); $tecdate=strtotime($tecdate); $date =$date-$tecdate; $creteria->addCondition('date_end-date_create<='.($date).'');
P.S. Напиши что ты пытаешь проверить и что у тебя за время приходит?
Код: Выделить всё
$d = explode(':',$model->time_out);
$time = 3600*$d[0] + 60*$d[1] + $d2; // заданное время в секундах
$criteria->condition('TIMESTAMPDIFF(SECOND, date_create, date_end) <= :time');
$criteria->params=array(':time'=>$time);