Greaser9780 Posted February 25, 2007 Share Posted February 25, 2007 I am trying to create a script based on time and expiry time. I want to set time limit for 12 hours. I thought set time=now() and exptime = now()+43200<----# of seconds. But it only added 4 hours and 12 minutes. Where did I go wrong? Link to comment https://forums.phpfreaks.com/topic/39982-script-control-with-time/ Share on other sites More sharing options...
superuser2 Posted February 25, 2007 Share Posted February 25, 2007 now() is not a native php function. Could you show us it's definition? Link to comment https://forums.phpfreaks.com/topic/39982-script-control-with-time/#findComment-193374 Share on other sites More sharing options...
Hooker Posted February 25, 2007 Share Posted February 25, 2007 now() doesn't exist natively to php, it exists in MYSQL though. Here are two possible solutions, one for PHP and one for MYSQL (depending on what you actualy want): - PHP $time = time() + (0 * 12 * 00 * 00); - MYSQL DATE_ADD(NOW(), INTERVAL 12 HOUR) Hope this helps Link to comment https://forums.phpfreaks.com/topic/39982-script-control-with-time/#findComment-193376 Share on other sites More sharing options...
Greaser9780 Posted February 25, 2007 Author Share Posted February 25, 2007 Shouldn't it be time() + (12 * 60 * 60) otherwise 0*12*0*0 = 0 Link to comment https://forums.phpfreaks.com/topic/39982-script-control-with-time/#findComment-193388 Share on other sites More sharing options...
Hooker Posted February 25, 2007 Share Posted February 25, 2007 i was just popping in a anything just as an example. Link to comment https://forums.phpfreaks.com/topic/39982-script-control-with-time/#findComment-193389 Share on other sites More sharing options...
Greaser9780 Posted February 25, 2007 Author Share Posted February 25, 2007 $time=mysql_query("UPDATE time SET time = now(), exptime = NOW()+ INTERVAL $hour HOUR, $minute MINUTE "); Link to comment https://forums.phpfreaks.com/topic/39982-script-control-with-time/#findComment-193390 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.