Jump to content

how to specify less than 7 days


shadiadiph

Recommended Posts

in my coding i want to display certain things in different colors

 

for example $expiry is a date value in the database  $status is just a css class i want to make it if $expiry == less than 7 days from the date value of expiry??? I have no clue i am just guessing ;(

 

if ($expiry ==  "> 7%d '$expiry'")
{
$status="status7days";
}

 

Link to comment
https://forums.phpfreaks.com/topic/141191-how-to-specify-less-than-7-days/
Share on other sites

You can fetch the expiry value from the database and then compare it.  Or you can ask the database to compare it for you.

 

Are you already fetching the expiry value from the database?  If so, please show the code.

 

How to do the comparison depends on what format the date is in.

mm one thing i failed to mention is that $expiry has more than one value in the database but when i call

 


$print expiry;

 

it displays 2009-01-20

 

this didn't work either and

$expiry == less than 7 days from the date value of expiry

was not code just an expample of what i am trying to acheive.

 

 

if (current time - 7 days ) < $expiry
{
$status="status7days";
}

 

when i just tried this

 

$expiry_ts = strtotime($expiry);
print $expiry_ts;

 

 

it displayed this 1232384400

sorry i didn't mean to say it was invalid code i just can't make sense of what you are saying to m it reads

expiry needs to be less than 7 days from the value of expiry

which to me is impossible because the way i read it was that there was only one expiry.

so if you have two expires one from the database and one from somewhere else

try

$expirya_ts = strtotime($expiry_from_db);
$expiryb_ts = strtotime($expiry_from_somewhere);
if($expirya_ts  < strtotime("-7 days",$expiryb_ts)){
    $status="status7days";
}

i think??

 

Scott.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.