Jump to content

[SOLVED] Comparing dates (today or yesterday)


5kyy8lu3

Recommended Posts

Hi.  I made a visitor log, and for the 'last visit' column, I want it to say 'today' or 'yesterday' if the last visit was today or yesterday.  The only problem is, I don't know how to tackle this beast.

 

I could put day, month, and year into their own variables and compare that way, but then I have the headache of worry about the 1st of the month (to where yesterday would actually be a high value).

 

I know I can use strtotime() but I don't know how I'd go about telling if a date is "yesterday" compared to today using that method.

 

Any ideas?  I save my dates as MMDDYYHHMMSS in my table but I can manipulate it as necessary.

 

Thanks ahead of time.

Hi.  I made a visitor log, and for the 'last visit' column, I want it to say 'today' or 'yesterday' if the last visit was today or yesterday.  The only problem is, I don't know how to tackle this beast.

 

I could put day, month, and year into their own variables and compare that way, but then I have the headache of worry about the 1st of the month (to where yesterday would actually be a high value).

 

I know I can use strtotime() but I don't know how I'd go about telling if a date is "yesterday" compared to today using that method.

 

Any ideas?  I save my dates as MMDDYYHHMMSS in my table but I can manipulate it as necessary.

 

Thanks ahead of time.

 

ok well I figured it out, i used gregoriantojd(); to convert to the julian day format and just took the difference, so if the difference was 0, it's today, if the difference is 1, it's yesterday, pretty simple.  php keeps surprising me with all these handy built in functions ;D

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.