Jump to content

date has passed function


ldoozer

Recommended Posts

If you can seperate the day, month, and year, convert the month to textual format (example, "august"), then yes, this is very possible, and quite easy.

 

$date = strtotime($day . $month . $year);

$now = strtotime("now");

if($now >= $date) {

  echo "that date has passed";

  } else {

  echo "That date has not yet passed";

  }

 

Should work fine, but remember, you need to have day, month, and year seperate and the month has to be in textual format.

why not use timestamp and simply go:

 

$now = .....

$to_check = .....

 

if ($to_check > $now ){echo "FUTURE!!!";}

else {echo "ANCIENT HISTORY MAN!!!";}

 

 

 

thats what id do.  you could then store the timestames and do what ever formatting you wanted with it,

 

what your currently doing really restricts formatting

 

 

good luck

Thanks that give me a good output but using that why wont this work :

$time = strtotime('09/04/2007');
$newdate = date('Y-m-d', $time);

$date = $newdate;
$now = strtotime("now");
if($now >= $date) {
  echo "that date has passed";
  } else {
  echo "That date has not yet passed";
  }

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.