plznty Posted January 29, 2011 Share Posted January 29, 2011 How could I make it so that if the $date variable is past than $memberdate then something shows else something else does. <?php $date = date('Y-m-d H:i:s', time()-3600); $memberdate = '2011-01-29 01:03:28'; ?> Thanks in advance, I realised I could convert it into a unix timestamp but there must be a better way. Ty. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted January 29, 2011 Share Posted January 29, 2011 Is $memberdate coming from a database query? Quote Link to comment Share on other sites More sharing options...
requinix Posted January 29, 2011 Share Posted January 29, 2011 if ($date > $memberdate) { Yes, actually, it does work. Quote Link to comment Share on other sites More sharing options...
plznty Posted January 29, 2011 Author Share Posted January 29, 2011 Yes Pikachu from a datetime format. Quote Link to comment Share on other sites More sharing options...
plznty Posted January 29, 2011 Author Share Posted January 29, 2011 Thank you requinix. Didn't think it would be that easy. Fast response also Quote Link to comment Share on other sites More sharing options...
requinix Posted January 29, 2011 Share Posted January 29, 2011 Didn't think it would be that easy. It only works when you satisfy some conditions: 1. All the date components are in descending order. Year, month, day, hour, minute, and second. In that order. Parts can be omitted (in both strings) but not rearranged. 2. The non-numeric characters (ie, separators, like /s and -s and spaces) must be identical in both strings. That means no month names. 3. Each pair of numbers must always be the same length as each other. Like DD/DD and YYYY/YYYY. The easiest way to do that is to zero-pad numbers to a fixed number of digits. So these won't work: 2010-Jan-31 / 2010-Feb-01 - months must be numbers 01-31-2010 / 02-01-2010 - not in descending order 2010-1-31 / 2010-2-1 - numbers are not the same lengths 2010-01-31 / 2010/02/01 - different separators 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.