Link to home
Start Free TrialLog in
Avatar of sabecs
sabecs

asked on

PHP mysql dates - compare dates in the format YYYYMMDD.

How do I compare dates in the format YYYYMMDD with PHP
For example; If I have a date 20050703, how do I check if this date is less than the current date minus 14 days?  
Also how do I check if this date is in the current year, current month, last month etc.?

Thanks...
ASKER CERTIFIED SOLUTION
Avatar of WoodyRoundUp
WoodyRoundUp

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of WoodyRoundUp
WoodyRoundUp

if ($timediff<0)
     echo "$day is less ".-($timediff/86400)." than today minus 14 days (".date("Ymd",$timestamp2).")<BR>";
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
what's wrong with mine?
It tells you how many days difference.
Beside, you can tell what year you are in straight away, according to your question.

I can't accept this, man.
All your questions are answered in my answer.
Hm. Well, I think I have spent time to find the answer for someone who can't appreciate. :(
yep you should have marked mine as assisted as WoodyRoundUp answered the question