Jump to content

Recommended Posts

I am creating an Expire Ban section in the database.

I have setup this

		$bantime = date("d m y, G:i:s");
	//setup time of expire
	$q = "INSERT INTO ".TBL_BANNED_USERS." VALUES ('$username', '$bantime', '$time', '$expire')";

 

The length of ban, is $time. How would I do

$expire = $bantime + $time;

$time value is in seconds. Would that be right.

I know timestamps are best done in MySQL. I prefer it this way though.

 

I like PHPFreaks new design. :)

Link to comment
https://forums.phpfreaks.com/topic/182425-how-would-i-do-datetime-add-seconds/
Share on other sites

You should be using the proper MySQL column types. Datetime is available to you. If you use the function mktime() properly, this will be pretty easy to accomplish. Also, your column Banlength is a bit redundant, seeing as you could get the ban length from the BanDate and ExpireDate columns, unless I'm mistaken otheriwse.

Well.. the banlength isn't needed in the database. It is however, needed to add onto the current timestamp, to make the ExpireDate.

 

If I change the BanDate from text, to Datetime...

What would I do for the rest, would mktime() be..

mktime(month day year hour:minute:second);

I'm not sure.

Then If I set that as a variable. How would I add the $time onto the mktime?

 

Sorry, I'm not so understanding.

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.