Jump to content

Simplest Way To Evaluate Two Dates?


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?





Link to comment
Share on other sites

This thread is more than a year old. Are you sure you have something important to add to it?

Join the conversation

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

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.