Jump to content


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


strtotime problem.

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?

[code=php:0] 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);

Share this post

Link to post
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]


[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";
$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

Share this post

Link to post
Share on other sites


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.