mkosmosports Posted January 9, 2007 Share Posted January 9, 2007 Quick question everyone. I have retrieved dates in "yyyymm" (%Y%c) format from mysql, then put them into an array. I now want the latest date so naturally I would make use of the max function. Ive noticed something though. The latest date I have in my db is 200701, however php doesnt count the 0 in the month, and it ends up being 20071. Is there any way to avoid that?Thanks in advance.... Quote Link to comment Share on other sites More sharing options...
chronister Posted January 9, 2007 Share Posted January 9, 2007 Store dates as a unix timestamp or in YYYY-MM-DD.Mysql will recognize the YYYY-MM-DD format and allow you to do things like finding dates between, date > $somevar, date < $somevar etc.The best way is to use unix timestamps as there is no debating which date is the earlier/later/equal to with that format.But to answer your question.. looks like change this yyyymm" (%Y%c)toyyyymm" (%Y%m)From Mysql Manual...%m Month, numeric (00..12)%c Month, numeric (0..12)Try that Quote Link to comment Share on other sites More sharing options...
mkosmosports Posted January 9, 2007 Author Share Posted January 9, 2007 Thanks Chronister. I should of figured that one out... :D Quote Link to comment 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.