Jump to content


strtotime problem.

  • Please log in to reply
1 reply to this topic

#1 xyn

  • Members
  • PipPipPip
  • Advanced Member
  • 779 posts
  • LocationNorthampton

Posted 26 September 2006 - 09:00 PM

Hey Guys,
I've got a small problem, I've gt very confused on how to use
strtotime, so from what i've read from php.net i have managed
to create a "time ban" the only problem is checking the ban when
the user logs in,

I have set the ban in "Minutes, OR hours OR days" and using the
below code to set the ban, could someone help me with the "unban" check?

if($_POST[perm] == "never"){
	$expire_date= "Never";
	$date = strtotime("now + $_POST[time] $_POST[type]");
	$expire_date = date("j, m, Y - H:i.s", $date);
	$date_now = strtotime("now");
	$now= date("j, m, Y - H:i.s", $date_now);

#2 sanfly

  • Members
  • PipPipPip
  • Advanced Member
  • 344 posts
  • LocationNew Zealand

Posted 26 September 2006 - 09:33 PM

Firstly, I dont think that you need the "now" in your $date strtotime, and I suspect that the way you have it written is wrong.  Try either:

$date = strtotime("+" . $_POST['time'] . " " . $_POST['type']);


$time = $_POST['time'];
$type = $_POST['type'];
$date = strtotime("+ $time $type");

and as a shortcut

$expire_date = date("j, m, Y - H:i.s", strtotime("+" . $_POST['time'] . " " . $_POST['type']));

For the $now time, you dont need to use strtotime, just having the code below will get the current date and time

$now= date("j, m, Y - H:i.s");

So the final code would be something along these lines

if($_POST['perm'] == "never"){
	$expire_date= "Never";
	$expire_date = date("j, m, Y - H:i.s", strtotime("+ " . $_POST['time'] . " " . $_POST['type']));
	$now= date("j, m, Y - H:i.s");

May require a bit of tweaking, but give it a go
If you're not part of the solution, you're part of the precipitate

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users