Jump to content

strtotime problem.


xyn

Recommended Posts

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?
thanks...

[code=php:0] if($_POST[perm] == "never"){
$expire_date= "Never";
}else{
$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);
}[/code]
Link to comment
Share on other sites

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:

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

or

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

and as a shortcut

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

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

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

So the final code would be something along these lines

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

May require a bit of tweaking, but give it a go
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.