Comparing 2 dates using strtotime()
Posted: Thu Oct 27, 2011 9:45 am
Man, do i have hard time with this one.... this is probably simple you will say.
I need to compare the received date of a product to see if this is a new product or not... simple ennough !
$purchdate = $db_field['DATEDEBUT'];// here DATEDEBUT is 2011-09-20
$strtoday = strtotime("now");
$isnewitem = strtotime($purchdate + 15);
if ($isnewitem >= $strtoday) {
$newstock = true;
} else {
$newstock = false;
}
here i want the product that are 15 days old or less to be selected as newstock. Looks like the +15 is not working here.
thanks.
I need to compare the received date of a product to see if this is a new product or not... simple ennough !
$purchdate = $db_field['DATEDEBUT'];// here DATEDEBUT is 2011-09-20
$strtoday = strtotime("now");
$isnewitem = strtotime($purchdate + 15);
if ($isnewitem >= $strtoday) {
$newstock = true;
} else {
$newstock = false;
}
here i want the product that are 15 days old or less to be selected as newstock. Looks like the +15 is not working here.
thanks.