Jump to content
MakeWebGames

Recommended Posts

Posted

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)");

Posted

time(), time()+46800

Not sure about unix_timestamp but I know time() will work :).

Posted

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

  • 3 weeks later...
Posted

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).

Posted
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.

Posted
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.

  • 2 weeks later...
Posted
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.

Posted
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.

Posted
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.

Posted (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 by Paul Evans
Posted
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
}

vader-fail.jpg

Posted (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 by Paul Evans
Posted
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.

Posted
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.

  • 3 months later...
Posted

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...