Jump to content

simple DateTime problem


Jakebert

Recommended Posts

I'm trying to grab the current time of the user's computer and compare it to two date times in the database. The dates in the database are stored in this format: "2012-06-24 00:00:00". This is the code I have:

 

//today's date
$date = new DateTime();

// since that comes back in UNIX format, change it so it matches the DB format
$now = date_format($date, 'Y-m-d H:i:s');


while ($output = mysqli_fetch_assoc($info)) 
{
	//let's check the open and close dates
	if (($now>$output['open_date']) || ($now<$output['close_date'])) {echo "There are no ballots for you at this time.";}
	else

	{	echo $output['display_name'];
		echo "<br />";
		echo $output['open_date'];
		echo "<br />";
	}
		}		
}

 

There's got to be a problem with the comparison line... I just can't tell what it is. Also where can I move the "there are not ballots for you at this time" so that it doesn't echo for every ballot?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.