php - trying to hide an event two days after it's passed -


i'm trying hide event 2 days after it's passed in php (using mysql query). there 2 date options. start date, , end date. can't seem figure out how make query work.

    $query->select('*');     $query->from('#__events_items');     $query->where('date2 >= "'.$today.'"');     $query->where('date2 <= "'.$sixmths.'"');     $query->where('state = 1');     $query->order('date1 asc'); 

i've tried

$today      = @date('y-m-d'); $enddate        = @date('y-m-d',(strtotime(@date('y-m-d')."+ 2 days"))); 

but end date won't greater or equal $enddate.. appreciated!

you can either modify today so:

$today = date('y-m-d', strtotime('-2 days')); 

or modify query :

 $query->select('*');  $query->from('#__events_items');  $query->where('date2 >= "'.$today.'" - interval 2 day');  $query->where('date2 <= "'.$sixmths.'"');  $query->where('state = 1');  $query->order('date1 asc'); 

i second better form since having $today represent 2 days ago nasty self documenting code.


Comments

Popular posts from this blog

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -