Jump to content

[SOLVED] Expire date not working :(


balkan7

Recommended Posts

i used follow fileds for date start and date expire:

banner_date varchar(100) NOT NULL,

banner_expire varchar(100) NOT NULL,

 

for inserting date i used function time(); in datebase look like this one: (1214930648) same in 2 fields,

but in exipration field i add more time like 1 month whit this function:

 

<?php
$add_date = mktime(date(H),date(i),date(s),date(m) + 1 ,date(d), date(Y));
        $until = date("d-m-Y H:i:s", $add_date);
        $result1 = dbquery("UPDATE ".$db_prefix."btr_banners set banner_expire = '".$add_date."' WHERE banner_id = ".$banner_id."");?>

 

now i used this code for check did banner expire time but not working:

<?php
$time = time();
		if ($data['banner_expire'] < $time) {
			$result3 = dbquery("UPDATE ".$db_prefix."btr_banners set banner_state = '0' WHERE banner_id = '".$banner_id."'");
		}?>

 

can someone help me where i wrong ?

Link to comment
https://forums.phpfreaks.com/topic/83888-solved-expire-date-not-working/
Share on other sites

Use DATETIME fields, not varchar, for date/times.

 

Store them in Y-m-d H:i:s format (d-m-Y is totally useless)

 

Easiest way to write current datetime and + 1 month is, eg

INSERT INTO table (banner_date, banner_expire) VALUES ( NOW(), NOW() + INTERVAL 1 MONTH)

i use now this function but whitout result :(

<?php
if (isset($_GET['banner_id']) && isNum($_GET['banner_id'])) $banner_id = $_GET['banner_id'];

$expire = dbquery("SELECT * FROM ".$db_prefix."btr_banners WHERE banner_id='$banner_id'");
	while($exp = dbarray($expire)) {
	$time = date("Y-m-d H:i:s");
	if ($exp['banner_expire'] < $time) {
	$result3 = dbquery("UPDATE ".$db_prefix."btr_banners SET banner_state='0' WHERE banner_id='$banner_id'");
	}
}
?>

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.