Jump to content

Only display if date is after current date (Date: YYYY - MM - DD)


Clarkie

Recommended Posts

Hey,

 

I'm using a script which allows you to click on a calendar to select the date to submit to the database.

 

The date is submitted like this: 2014-02-08

 

Is there a really simple way to prevent rows showing if the date is in the past?

 

Something like this:

if($currentdate < 2014-02-08 || $currentdate == 2014-02-08) {

 

}

 

Thanks very much,

Jack

Link to comment
Share on other sites

Check strtotime function.

It converts a date into Unix timestamp.

 

You can convert both current date and date to  compare in unix timestamp [which is in seconds] and do a <= comparison.

Thanks that's exactly what I need!

 

Your question isn't very clear, but maybe something like this is what you mean?

 

SELECT field FROM table WHERE date >= CURDATE()

Thanks to you also I'll use this to actually get the right rows from the db. :)

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.