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? Link to comment https://forums.phpfreaks.com/topic/92360-working-with-date/ 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); Link to comment https://forums.phpfreaks.com/topic/92360-working-with-date/#findComment-473255 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 Link to comment https://forums.phpfreaks.com/topic/92360-working-with-date/#findComment-473257 Share on other sites More sharing options...
drisate Posted February 22, 2008 Share Posted February 22, 2008 Yeah nice hehe Link to comment https://forums.phpfreaks.com/topic/92360-working-with-date/#findComment-473260 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.