Jump to content


Photo

Calculate date no more than 365 from now


  • Please log in to reply
1 reply to this topic

#1 freakness883

freakness883
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 14 July 2006 - 05:04 AM

I was hoping to use the following code to make sure that a date entered is not more than 365 from now:

!(floor((time() - strtotime($expiration_date))/86400) > 365)

This condition fails. Does anyone know why?

#2 toplay

toplay
  • Staff Alumni
  • Advanced Member
  • 973 posts

Posted 14 July 2006 - 05:57 AM

It depends how you're using it because you have !

Example:
$expiration_date = '01/01/2006';

if ((floor((time() - strtotime($expiration_date))/86400) > 365)) {
    echo 'outside of 365 days';
} else {
    echo 'within 365 days';  // displays this

}

Using 07/12/2005 date with the example code will display that it's outside the 365 day window.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users