jakebur01 Posted February 21, 2008 Share Posted February 21, 2008 I want to use the date(Y-M-D) function to store a modified date and an expiration date. How could I create an expiration date based on todays date. Example. todays date + 12 months = expiration. Also how could I display how many days it is until the expiration date? Quote Link to comment Share on other sites More sharing options...
drisate Posted February 22, 2008 Share Posted February 22, 2008 Use mktime() $tomorrow = mktime(0, 0, 0, date("m") , date("d")+1, date("Y")); $lastmonth = mktime(0, 0, 0, date("m")-1, date("d"), date("Y")); $nextyear = mktime(0, 0, 0, date("m"), date("d"), date("Y")+1); Quote Link to comment Share on other sites More sharing options...
Barand Posted February 22, 2008 Share Posted February 22, 2008 If the dates are being stored in a MySQL database you can use its inbuilt date functions ... SET expiry = CURDATE() + INTERVAL 12 MONTH SELECT DATEDIFF(CURDATE(), expiry) as days_to_expiry FROM tablename Quote Link to comment Share on other sites More sharing options...
drisate Posted February 22, 2008 Share Posted February 22, 2008 Yeah nice hehe 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.