Jump to content

strtotime


eMonk

Recommended Posts

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

$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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.