NZ_Kiwis;10993582 wrote:Yes but with the dateTime class you can only go to 2038
Says who? (And whoever said that, be sure to tell them they were mistaken. 😉)
The PHP manual certainly has a different opinion; from the man page [man]intro.datetime[/man]:
PHP Manual wrote:The date and time information is internally stored as an 64-bit number so all imaginable dates (including negative years) are supported. The range is from about 292 billion years in the past to the same in the future.
NZ_Kiwis wrote:If the GameDate updated every, I dunno 15 seconds, would that be much load on my server if I had 500 people playing this game at once?
Whether or not your server has the necessary resources to keep up at all is something you'd want to do some benchmarking and profiling to determine. However, if we're talking about efficiency, let's compare your method versus my proposed method. You are wanting to:
Execute a query to SELECT the date from all rows in the DB.
Loop through the result set, fetching each row one-by-one from the DB into PHP. For each row, you also:
Perform some calculation and/or string manipulation in PHP to update the date.
Execute a SQL query to update that row's date value in the DB with the new value from above.
In other words, you're going to execute n+1 SQL queries, where n is the number of rows in the table. In other words, you're up to 4(n+1) SQL queries per hour just to update the time.
My suggestion was to simply:
Execute a query to UPDATE all rows by adding 15 minutes to the rows' previous values, respectively.
That's only 1 query, or 4 queries per hour (regardless of the number of rows in the table).