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
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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.