eMonk Posted September 12, 2011 Share Posted September 12, 2011 I'm trying to add 5 days to $today date: <?php $exp_date = "2011-09-11"; $todays_date = date("Y-m-d"); $today = strtotime("+5 days", $todays_date); $expiration_date = strtotime($exp_date); if ($expiration_date > $today) { echo "Valid: Yes"; } else { echo "Valid: No"; } ?> Is +5 days used wrong? Quote Link to comment https://forums.phpfreaks.com/topic/246936-strtotime/ Share on other sites More sharing options...
trq Posted September 12, 2011 Share Posted September 12, 2011 Is +5 days used wrong? No, but $todays_date needs to be a timestamp. In this case you can leave it out all together. Quote Link to comment https://forums.phpfreaks.com/topic/246936-strtotime/#findComment-1268189 Share on other sites More sharing options...
aruns Posted September 12, 2011 Share Posted September 12, 2011 $todays_date = strtotime("now"); use like this Quote Link to comment https://forums.phpfreaks.com/topic/246936-strtotime/#findComment-1268236 Share on other sites More sharing options...
Pandemikk Posted September 12, 2011 Share Posted September 12, 2011 $todays_date = strtotime("now"); use like this Why would he do that? The optional parameter in strtotime defaults to the current timestamp if none is provided. http://php.net/manual/en/function.strtotime.php And anyway, time() should be used instead of strtotime("now"). Just follow with what thorpe stated. Quote Link to comment https://forums.phpfreaks.com/topic/246936-strtotime/#findComment-1268241 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.