Like Choroba has already pointed out, use a module to handle the date/time calculations for you. Use that module to evaluate the products_last_modified value, something he also pointed out. Then, it looks like you could update your if statement to include another clause, something along the lines of:
# update when price/stock conditions met
if (($data->{'price'} <= $product_price && $data->{'quantity'} > 0).
|| ($product_quantity == 0 && $data->{'quantity'} > 0)
|| ($products_last_modified <= 12))