Jump to content

How would I do DateTime add seconds


c-o-d-e

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.

Archived

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

×
×
  • 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.