I have this variable:
$today = date("Y-m-d H:i:s"); // for example today is 2015-10-04 12:30:00
$first_date = "2015-10-01 00:00:00";
$second_date = "2015-10-02 00:00:00";
$third_date = "2015-10-03 00:00:00";
$fourth_date = "2015-10-04 00:00:00";
$fift_date = "2015-10-06 00:00:00";
//place the function - and result to $output $output = "result";
And I need this. If variable of any day is the nearliest to $today from PAST date, set $output = 1; ... If date is in BEFORE $today - ignor thi variable.
Anyone know?
For better understanding - I have a DATE in database like this in rows:
- ID_product = 4; ID_special_price = 20; from = 2015-10-03 00:00:00; to = 2017-04-30 00:00:00;
- ID_product = 4; ID_special_price = 21; from = 2015-10-03 00:00:00; to = 2015-10-04 00:00:00;
- ID_product = 4; ID_special_price = 22; from = 2015-10-04 00:00:00; to = 2015-10-05 00:00:00;
- ID_product = 4; ID_special_price = 23; from = 2015-10-05 00:00:00; to = 2015-10-07 00:00:00;
So this is a special price from(start) and to(end). In my case, I need to foreach ID_product 4 times and pick up only one row - now it will be row number 3. with ID_special_price = 22, becose this DATE - from(2015-10-04 00:00:00) today (2015-10-04 12:30:00) to(2015-10-05 00:00:00) is the nearest "to" actually date and still active, becose end of this special offer ending 2015-10-05 00:00:00.