title: PHP expire date
body: <p><strong>Background info</strong></p>
  
  <p>I'm creating a donation/purchase system for a game garrys mod. when a user donates through paypal i have php code that handles the ipn and enters data into a database it also generates a serial key and emails this to the user who can then enter this in game, when the user enters serial in-game it checks the database sees if the key is valid and then executes the relevant lua code. The system so far works perfectly however the donation packages last for a certain amount of time 30 days, 90 days, 180 days and 365 days. </p>
  
  <p>What i want to achieve is when the user enters the key in-game i will have lua code that stores the players steam id as well as the day they redeemed it and for how long there package will last for. i will setup a cron job to run a script that checks the database if the key is used, if the key has been used it will check to see if, for example, 30 days have past since they redeemed the key, if its below the 30 days do nothing if its over the 30 days then it will change a value in the table from 0 to 1.</p>
  
  <p><strong>Question</strong></p>
  
  <p>The part i'm really struggling to get my head around is how to store the date and check the date, initially i thought i would use day of the year but then comes the issue of a year change from 365 to 0 what if someone purchases it in December for 90 days then errors would occur. So how can i do this reliably accounting for the year changing?</p>
  
  <p><strong>Thanks to everyone who posted answers and extremely quickly as well, i think i have enough to work with for now, thanks again for your time</strong></p>