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? Quote Link to comment 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? Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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 "); Quote Link to comment 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.