Comparing YYYY-MM-DD dates

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mevets
Forum Newbie
Posts: 23
Joined: Fri Sep 15, 2006 10:06 am

Comparing YYYY-MM-DD dates

Post by mevets »

I cannot figure out how to compare (earlydate < today) dates. I have dates in YYYY-MM-DD (ex. 2007-04-13) format. Most of the tutorials explain how to do this at a myqsl level, but I want to do it after my query at the php level. So what exactly must I do to compare dates in the format have them?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

compare them as strings. no need for conversion here.

Code: Select all

var_dump("2004-01-02" > "2003-12-20"); // bool(true)
Post Reply