balkan7 Posted December 31, 2007 Share Posted December 31, 2007 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 ? Quote Link to comment https://forums.phpfreaks.com/topic/83888-solved-expire-date-not-working/ Share on other sites More sharing options...
Dane Posted December 31, 2007 Share Posted December 31, 2007 try $time = mktime(time()); Quote Link to comment https://forums.phpfreaks.com/topic/83888-solved-expire-date-not-working/#findComment-426951 Share on other sites More sharing options...
hitman6003 Posted December 31, 2007 Share Posted December 31, 2007 try $time = mktime(time()); At best, that would be redundant...at worst, it would throw an error. Echo out your variables and make sure they are values that you are expecting. You may be getting an invalid value. Quote Link to comment https://forums.phpfreaks.com/topic/83888-solved-expire-date-not-working/#findComment-426958 Share on other sites More sharing options...
balkan7 Posted December 31, 2007 Author Share Posted December 31, 2007 i have tested whit that function but not result Quote Link to comment https://forums.phpfreaks.com/topic/83888-solved-expire-date-not-working/#findComment-426963 Share on other sites More sharing options...
Barand Posted December 31, 2007 Share Posted December 31, 2007 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) Quote Link to comment https://forums.phpfreaks.com/topic/83888-solved-expire-date-not-working/#findComment-427006 Share on other sites More sharing options...
balkan7 Posted December 31, 2007 Author Share Posted December 31, 2007 ok i change so now i need function for check date for expiration... Quote Link to comment https://forums.phpfreaks.com/topic/83888-solved-expire-date-not-working/#findComment-427018 Share on other sites More sharing options...
balkan7 Posted January 1, 2008 Author Share Posted January 1, 2008 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'"); } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/83888-solved-expire-date-not-working/#findComment-427030 Share on other sites More sharing options...
balkan7 Posted January 1, 2008 Author Share Posted January 1, 2008 my mistake about checking code for expiration date, now i fix the problem thank you guys for help !! Quote Link to comment https://forums.phpfreaks.com/topic/83888-solved-expire-date-not-working/#findComment-427043 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.