Jump to content

Datetime / difference between dates conundrum


radar

Recommended Posts

Hello,

 

First off let me state that the website I am working on is my hosting company website / web development.  Through my years of web development I have yet to need to do this.

 

I am working on the front end hosting stuff now,

 

I have 2 dates...

 

one is just a 'string' brought by $date = date();

 

the other is DATETIME in the database, is $date1 = "select renewal_date from hosting_orders where order_id = '$id'"

 

which with the rest of the code will have the date like

 

2008-05-30 00:19:16

 

So what I am trying to do is this:

 

Basically i am building a 'client' area for my website.  I am not going to be responsible for renewing the hosting, so in the client area I need to get the current date and the renewal_date and if the current date is equal to or greater than renewal_date minus 5 days it'll show the link to process a payment for hosting.

 

Basically I am not sure how to do this what so ever...

 

-- On a side note --

 

If i have another field called 'date_activated' which i want to be blank upon order, that is something i want to add in later after the hosting account has been setup and activated. 

 

I've never played with this, so i dont know if it is possible to make a datetime field in mysql database be nothing.

 

Anyway any help on this would be appreciated.

 

Thanks,

-- radar

I've been doing more research and I wonder if this would work...

$dday = now();

$dday = strtotime($dday); //$dday is a timestamp

$query = "SELECT * FROM hosting_orders WHERE UNIX_TIMESTAMP(renewal_date) =<

$dday";

 

I might be totally wrong on this, but maybe it might work?  of course once its in a unix timestamp setup, i'd have to figure out how to 5 days off $dday

 

maybe i'm thinking way too complicated here too i dunno...

 

anyway, as always any help appreciated.

 

-- Radar

 

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.