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? 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. 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 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. Link to comment https://forums.phpfreaks.com/topic/246936-strtotime/#findComment-1268241 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.