newttster Posted May 4, 2012 Posted May 4, 2012 Say I want something to last 13 hours. 13 hours equals 46800 seconds. On my table I have a begintime field and an endtime field. Would this record the correct times? ("INSERT INTO table (begintime,endtime)VALUES (unix_timestamp(), unix_timestamp() + 46800)"); Quote
Guest Posted May 4, 2012 Posted May 4, 2012 time(), time()+46800 Not sure about unix_timestamp but I know time() will work :). Quote
newttster Posted May 4, 2012 Author Posted May 4, 2012 Thanks iExze. So the time() function works the same way as the unix_timestamp() function then? Quote
rulerofzu Posted May 4, 2012 Posted May 4, 2012 Thanks iExze. So the time() function works the same way as the unix_timestamp() function then? Oh dear..... time returns the current unix timestamp Quote
newttster Posted May 4, 2012 Author Posted May 4, 2012 Oh dear..... time returns the current unix timestamp Yes ... I got that after reading up further on the function, thanks. Quote
Spudinski Posted May 4, 2012 Posted May 4, 2012 But... I bet none of you knew this; SQL SELECT IFNULL(('12-04-2001' = '12/04/2001'), 'Nope', 'Yep'); PHP var_dump(('12-04-2001' === '12/04/2001')); Quote
rulerofzu Posted May 4, 2012 Posted May 4, 2012 Probably didnt know that but cant really be bothered to try it. If you put in 12-04-2001 === 12/04/2001 Into google it comes up with some rather non related bizarre results lol Quote
rulerofzu Posted May 4, 2012 Posted May 4, 2012 Yeah the issue is get someone to set up your server properly as you dont know what your doing! Quote
Spudinski Posted May 4, 2012 Posted May 4, 2012 Couldn't possibly be that you are wrong and they will always be the same, could it? *sigh* Apache takes time of `clock`, but normally Apache doesn't hold any time value. Quote
Arson Posted May 21, 2012 Posted May 21, 2012 You really don't need the begintime field. If you want to be able to display the beginning time, simply do: $begintime = ($endtime - (13*60)*60); or since you've already done the math and gotten the seconds for yourself: $begintime = $endtime - 46800; Then you have one less field taking up space in the database (which can be significant if there are several rows). Quote
newttster Posted May 22, 2012 Author Posted May 22, 2012 You really don't need the begintime field. If you want to be able to display the beginning time, simply do: $begintime = ($endtime - (13*60)*60); or since you've already done the math and gotten the seconds for yourself: $begintime = $endtime - 46800; Then you have one less field taking up space in the database (which can be significant if there are several rows). It's not so much a question of displaying the times. It's more that there will be 13 individual time frames within the begintime and endtime that will be used for certain actions and tallies. It's going to take some time for me to figure it out, but if it does work the way I hope it will ... it's possible that I may be able to use it the way you are suggesting. So thanks for your suggestion. Quote
HauntedDawg Posted May 22, 2012 Posted May 22, 2012 Yeah the issue is get someone to set up your server properly as you dont know what your doing! Stop trying to be a smartASS where ever you go. If your blind, he said "Your hosts", which mean, shared hosting. Now how is he going to get someone to set up their server properly when they can't? Get off your high horse. Quote
versus Posted June 4, 2012 Posted June 4, 2012 So let's say your hosts has it's database running a European time zone (unix_timestamp in database) and the server running apache is configured on a US time zone (time() function) See an issue? I see you managed to confuse a number of people there. :) Long answer: no issue because both time() function in PHP and unix_timestamp() function in MySQL reference the same value: seconds since 00:00:00 UTC January 1, 1970 (disregarding leap seconds). Using unix_timestamp()+13*60*60 will be exactly 13 hours from now, regardless of what the local timezone is where you read that statement and regardless of the delta of your local timezones. Local timezone is a relative measure, POSIX time (or Unix time or Unix epoch) is absolute. Quote
Spudinski Posted June 4, 2012 Posted June 4, 2012 I see you managed to confuse a number of people there. :) Long answer: no issue because both time() function in PHP and unix_timestamp() function in MySQL reference the same value: seconds since 00:00:00 UTC January 1, 1970 (disregarding leap seconds). Using unix_timestamp()+13*60*60 will be exactly 13 hours from now, regardless of what the local timezone is where you read that statement and regardless of the delta of your local timezones. Local timezone is a relative measure, POSIX time (or Unix time or Unix epoch) is absolute. Actually, POSIX time.h follows ISO C. But yes, you are correct, SRB is.. awkwardly wrong. Unix timestamps are the same, no matter what part of the world(or timezone) you are in. Hence UTC, or CUT. Quote
rulerofzu Posted June 4, 2012 Posted June 4, 2012 Stop trying to be a smartASS where ever you go. If your blind, he said "Your hosts", which mean, shared hosting. Now how is he going to get someone to set up their server properly when they can't? Get off your high horse. Thanks for sharing your relevant post there dawg. As ive mentioned before contact me by PM if you wish to make a fool of yourself. Quote
Paul Evans Posted June 4, 2012 Posted June 4, 2012 (edited) wow a spam post and i wasn't involved (until now) $thirteen_hours = ($_SERVER['REQUEST_TIME']+46800); use as you wish but like arson said no need for begin time only end and it's simple to check say you put it in a db table $whatever = mysql_fetch_object(mysql_query('SELECT `endtime` FROM `table`')); if ($whatever->endtime <= $_SERVER['REQUEST_TIME']) { //do something } Edited June 4, 2012 by Paul Evans Quote
Spudinski Posted June 4, 2012 Posted June 4, 2012 wow a spam post and i wasn't involved (until now) $thirteen_hours = ($_SERVER['REQUEST_TIME']-46800); use as you wish but like arson said no need for begin time only end and it's simple to check say you put it in a db table $whatever = mysql_fetch_object(mysql_query('SELECT `endtime` FROM `table`')); if ($whatever->endtime <= $_SERVER['REQUEST_TIME']) { //do something } Quote
Paul Evans Posted June 4, 2012 Posted June 4, 2012 (edited) LMAO oops - instead of + Spudi :P you been waiting for me to make a mistake for a while or something :D i must of done it to you huh :) Oh wait yeah LMAO Edited June 4, 2012 by Paul Evans Quote
Spudinski Posted June 4, 2012 Posted June 4, 2012 LMAO oops - instead of + Spudi :P you been waiting for me to make a mistake for a while or something :D i must of done it to you huh :) Oh wait yeah LMAO Actually, the fail was for the REQUEST header as well as the calculation mistake. Quote
Paul Evans Posted June 4, 2012 Posted June 4, 2012 i originally assumed that but there is a minor difference between time() and request maybe a second at max so don't really see the fail. Funny tho lol Quote
Spudinski Posted June 4, 2012 Posted June 4, 2012 i originally assumed that but there is a minor difference between time() and request maybe a second at max so don't really see the fail. Funny tho lol Leap seconds, UTC, POSIX, ISO, blah blah blah. Proper implementation would be time(), but what-the-hell. Quote
newttster Posted June 5, 2012 Author Posted June 5, 2012 Thank you everyone for your help and suggestions with this. It is greatly appreciated. Quote
newttster Posted September 22, 2012 Author Posted September 22, 2012 Yes ... I am back to this. :) I am trying to set it up so that when my war ends ... it will delete the record from the table. I realize that I have to do a comparison of the current time and the time that the war ends, which is already stored in a table. My confusion lies in how and where I would implement this code. I have read all the various time type functions that I can find ... but they all give examples with interval or do comparisons to show the difference. I already know how to do the difference comparison as I have set up a count down clock for the players to see how much time is left until the end of the war. I really am stumped on this. I don't know how to write it, which file it would go in or even if I should use php or something else. Quote
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.