if (mktime(date("U",$memberexpiry)) - (date("U")) < (60*60*24*20)) {
Above code is always returning as date difference less than the 20 days even when it's greater than 10 years!
I must have the format incorrect - any pointers please?
Yes, you are using the wrong syntax for the mktime() function. If you want the number of days between two timestamps, try this:
$daydiff = ceil(( time() - $memberexpiry ) / ( 3600*24)); if( $daydiff <= 20 ) { // $daydiff is less (or equals) 20 }
-- lilleman
thanks, as $memberexpiry is in YYYY-MM-DD format, will your code still work?
Originally posted by lottos thanks, as $memberexpiry is in YYYY-MM-DD format, will your code still work?
No, but neither would your code. Try [man]strtotime[/man].