xyn Posted September 26, 2006 Share Posted September 26, 2006 Hey Guys,I've got a small problem, I've gt very confused on how to usestrtotime, so from what i've read from php.net i have managedto create a "time ban" the only problem is checking the ban whenthe user logs in,I have set the ban in "Minutes, OR hours OR days" and using thebelow 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 https://forums.phpfreaks.com/topic/22160-strtotime-problem/ Share on other sites More sharing options...
sanfly Posted September 26, 2006 Share Posted September 26, 2006 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 https://forums.phpfreaks.com/topic/22160-strtotime-problem/#findComment-99237 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.