Jump to content

Comparing two date values.


mat-tastic

Recommended Posts

Hey Guys,

 

I have never had to do this before, but someone wants me to help them.

 

I have done the rest of the coding for the system, however:

 

The client has to renew their server (TS Server) and two weeks after that the renew deadline day, they want the servers to be removed if they have not renewed in that two weeks.

 

How would I work out when two weeks has passed from the renew date?

 

e.g two weeks after 2008/06/05

Link to comment
https://forums.phpfreaks.com/topic/126655-comparing-two-date-values/
Share on other sites

i have just been working on a somewhat similar issue myself.

 

some question need to be answered first for the easiest solution.

 

1. what version of php are you using?

2. how is the date stored now?

3. how automated does this need to be?

  (i.e. is this script going to run on it's own at a given time?, or will the user manually run the script?)

 

I ask what version of PHP you have because there are inherent classes for dealing with Date and Time in 5.2.x

 

Answer those up and we can figure something out for you.!

 

-C

 

 

Sorry not to sure i understand what you mean?

 

The script would be run manually.

 

It just needs to check what date it would be if it was two weeks after the renewal data in the database, then compare that to the current date.

 

if the current date is equal or past it, it kills the server.

SELECT `account` FROM `table` WHERE DATE_ADD(`expires`, INTERVAL 2 WEEK) > NOW()

 

Any rows that are returned have an `expires` value older than 2 weeks.

 

if expires + 2 week > now() then the records are younger than 2 weeks

 

for older than 2 weeks you are looking for

 

expires < NOW() - INTERVAL 2 WEEK

SELECT `account` FROM `table` WHERE DATE_ADD(`expires`, INTERVAL 2 WEEK) > NOW()

 

Any rows that are returned have an `expires` value older than 2 weeks.

 

if expires + 2 week > now() then the records are younger than 2 weeks

 

for older than 2 weeks you are looking for

 

expires < NOW() - INTERVAL 2 WEEK

 

Thanks to both of you, I will report back shortly.

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.