Jump to content

Simplest Way To Evaluate Two Dates?


Drongo_III

Recommended Posts

Hi Guys

 

Simple question but as I dont tend to work with dates much I figured I'd get some advice.

 

I have a DB table and one of the fields is the 'date of publish' in the format 'YYYY-MM-DD' and based on whether the date is in the future or the past I need to display the row data.

 

What I was wondering is whether a method as simple as the following is a viable method to determine whether the date from the db is in the future or not:

  1. strtotime() on date from database
  2. Get current time()
  3. use the php min function to determine if the date in the database is larger than current time - which would indicate it's in the future.

Or is that too simplistic and stupid?

 

The other option I am playing with is DateTime::diff but as I need to evaluate a large number of values in this way it seems a bit heavy.

 

Any opinions on whether i am on the right track, and if so, which you'd advise?

 

Thanks,

 

Drongo

Link to comment
https://forums.phpfreaks.com/topic/270885-simplest-way-to-evaluate-two-dates/
Share on other sites

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.