barkster Posted September 8, 2006 Share Posted September 8, 2006 I have the worst time with dates and times. I have a timestamp field that I need to add thirty days to and then check if it has expired against todays date/time. Of course I can't get it to work. Here is what I have, any help would be appreciated.[code]$created = mysql_result($LoginRS, 0, 'CreateDate');$created = date("Y-m-d H:i:s",$created);$created = date('Y-m-d H:i:s',strtotime("+30 day", $created));if($created < time()) { print "Expired"; die; } else { print "Not Expired"; die;}[/code] Quote Link to comment Share on other sites More sharing options...
Orio Posted September 8, 2006 Share Posted September 8, 2006 Try changing the script to:[code]<?php$created = mysql_result($LoginRS, 0, 'CreateDate');$expire = strtotime("+30 day", $created));if($expire < time()) { print "Expired"; die; } else { print "Not Expired"; die;}?>[/code]Orio. Quote Link to comment Share on other sites More sharing options...
king arthur Posted September 8, 2006 Share Posted September 8, 2006 You're trying to compare a date string with a timestamp, so of course it doesn't work. It's simpler if you do[code]<?php$created = mysql_result($LoginRS, 0, 'CreateDate') ;if($created < time() - 30 * 24 * 60 * 60) { print "Expired"; die; } else { print "Not Expired"; die;}?>[/code] Quote Link to comment Share on other sites More sharing options...
barkster Posted September 8, 2006 Author Share Posted September 8, 2006 Gracious, I'll try that Mr. Arthur. 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.