5kyy8lu3 Posted January 8, 2009 Share Posted January 8, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/139933-solved-comparing-dates-today-or-yesterday/ Share on other sites More sharing options...
5kyy8lu3 Posted January 8, 2009 Author Share Posted January 8, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/139933-solved-comparing-dates-today-or-yesterday/#findComment-732135 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.