> I have a datetime field in one of my mysql tables...when > displaying some of > my records I want to display the date in the aforementioned > datetime field, > but if the date is today I want to display "today" instead. > If the date is > yesterday I want it to display that .... so I how do I > compare the date in > my record to todays date? Thanks
First up, extract your date as part of your query in a standard format - if you're looking to do date manipulations you're probably going to be benefit from extracting it as a unix timestamp. Once you've got your date information, along with whatever else you're extracting, you can then process it in php. You'll most likely have some sort of while() loop to increment through your query data. While you're incrementing through you can do an test the date information against "today" and "yesterday". Have a read of the php manual for date() and mktime() as you'll almost certainly need to use these two functions. Basically what you'll need to do is test to see if the date information from your database query is the same as your date information based on working out what "today" or "yesterday" are when expressed in the same format as the date information from your database. The rest is pretty much display stuff - substitute date information for appropriate words as required. Hope that heads you in the right direction. CYA, Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php