nocniagenti Posted March 23, 2009 Share Posted March 23, 2009 I have memberships where expiration format date is as follows Your membership will expire on 05/15/2009 code to output is print "Your membership will expire on " . date('m/d/Y', strtotime($expire)); where $expire is being pulled from session that has the data , what I need is some math to remind user to renew membership or show renew link, 10 or 15 days before membership expires. something like if($expire < 10days){ echo 'Renew link'; } Any help is appreciated Link to comment https://forums.phpfreaks.com/topic/150766-need-some-date-expiration-help-please/ Share on other sites More sharing options...
The Little Guy Posted March 23, 2009 Share Posted March 23, 2009 $tenday = strtotime('now -10 days'); $exp = strtotime($expire); if($exp <= $tenday){ echo 'Membership expires in 10 days or less.'; } Link to comment https://forums.phpfreaks.com/topic/150766-need-some-date-expiration-help-please/#findComment-792112 Share on other sites More sharing options...
taquitosensei Posted March 23, 2009 Share Posted March 23, 2009 I would do this if(date("Y-m-d", strtotime("+10 days"))==date("Y-m-d", strtotime($expire))) { echo 'Renew Link'; } or +15 days I have memberships where expiration format date is as follows Your membership will expire on 05/15/2009 code to output is print "Your membership will expire on " . date('m/d/Y', strtotime($expire)); where $expire is being pulled from session that has the data , what I need is some math to remind user to renew membership or show renew link, 10 or 15 days before membership expires. something like if($expire < 10days){ echo 'Renew link'; } Any help is appreciated Link to comment https://forums.phpfreaks.com/topic/150766-need-some-date-expiration-help-please/#findComment-792117 Share on other sites More sharing options...
nocniagenti Posted March 23, 2009 Author Share Posted March 23, 2009 Does not work , tried both , this is second snipet , user expire set to 3-25-09 foreach ($_SESSION['_getsubscription'] as $p){ if ($p['completed']) $expire = $p['expire_date']; } if(date("m-d-Y", strtotime("+10 days"))==date("m-d-Y", strtotime($expire))) { echo 'Renew NOW'; }else{ print "Your membership will expire on " . date('m-d-Y', strtotime($expire)); } I get Your membership will expire on 03-25-2009 Link to comment https://forums.phpfreaks.com/topic/150766-need-some-date-expiration-help-please/#findComment-792120 Share on other sites More sharing options...
taquitosensei Posted March 23, 2009 Share Posted March 23, 2009 Just before the if state put this echo "10 Days from now: ".date("m-d-Y",strtotime(+10 Days))."<br>"; echo "Expiration Date: ".$expire; to make sure that the expiration date variable is 10 days or 15 days whichever you're using, from today and that they're the same format. Does not work , tried both , this is second snipet , user expire set to 3-25-09 foreach ($_SESSION['_getsubscription'] as $p){ if ($p['completed']) $expire = $p['expire_date']; } if(date("m-d-Y", strtotime("+10 days"))==date("m-d-Y", strtotime($expire))) { echo 'Renew NOW'; }else{ print "Your membership will expire on " . date('m-d-Y', strtotime($expire)); } I get Your membership will expire on 03-25-2009 Link to comment https://forums.phpfreaks.com/topic/150766-need-some-date-expiration-help-please/#findComment-792138 Share on other sites More sharing options...
nocniagenti Posted March 23, 2009 Author Share Posted March 23, 2009 for Expiration Date: 2009-03-25 Your membership will expire on 2009-25-03 and echo "10 Days from now: ".date("m-d-Y",strtotime(+10 Days)); is giving me syntax error, unexpected T_STRING in line 53 which is echo "10 Days from now: ".date("m-d-Y",strtotime(+10 Days)); Link to comment https://forums.phpfreaks.com/topic/150766-need-some-date-expiration-help-please/#findComment-792147 Share on other sites More sharing options...
nocniagenti Posted March 23, 2009 Author Share Posted March 23, 2009 no wait echo "Expiration Date: ".$expire." <br />"; is Expiration Date: 2009-03-25 Your membership will expire on 03-25-2009 Link to comment https://forums.phpfreaks.com/topic/150766-need-some-date-expiration-help-please/#findComment-792150 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.