Jump to content

Recommended Posts

Can anyone guide me to a tutorial or just tell me (if it's easier than I think it is :) ) of how you can take two dates in PHP (we'll call them $date1 and $date2) and compare them to see if date1 is BEFORE or AFTER date 2?

 

Is there a simple way to do this, or do they have to be broken down to seconds and THEN compared (like if the date1 second total is higher than the date2 second total, then we know it comes AFTER date2).

 

FYI, my dates are stored in mysql as type "date" (i.e. in the format of XXXX-XX-XX)

 

Any help would be appreciated, thanks much!

 

-Greg

 

ADD-ON:  If I just have $date1 and $date2 and they are both in the same format  from mysql (i.e.  type "date"), then can I just explicitly say "if ($date1 > $date2)"?

 

I just tried this and it seems to be working but I didn't think that would work that easily.

 

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.