Jump to content

Recommended Posts

G'day, ive got a script on my website that displays when the mysql table was last updated, but the downside is that its 2 hours behind.

For example, I updated the db (table) at 1155pm (Brisbane time), and yet it shows the db (table) was last updated at 955pm.

 

Here is the code i'm using, and can it display the true time?

$res = mysql_query("SHOW TABLE STATUS FROM database LIKE 'table'") ;
echo "<tr><td colspan=2 align=center>Database Updated: ". date('l, F j, Y @ g:i a', strtotime(mysql_result($res,0,'Update_time')))."</td></tr>";

Link to comment
https://forums.phpfreaks.com/topic/156530-table-status-time-incorrect/
Share on other sites

If you want the server's time to be that of a specific time zone, the best way is to set the time zone that you want it to use. It would help if you showed or stated where the value was produced, but if it was produced using the mysql server functions in the query, then you should set the mysql server's time zone. If this is shared hosting, you should look at the per-connection time zone information at the link provided above -

Per-connection time zones. Each client that connects has its own time zone setting, given by the session time_zone variable. Initially, the session variable takes its value from the global time_zone variable, but the client can change its own time zone with this statement:

 

mysql> SET time_zone = timezone;

 

You would set this immediately after every connection your script makes to the database.

The server I use is a paid server, so which means its proably shared with who knows how many other people.

If it's changing the servers time, I would suspect I wouldn't be able to do that, would I?

 

I just thought there maybe a simple process that when it displays the time using that bit of code previously supplied, that there would be a way to add 2 hours to it.

 

I've only just gotten into mysql, so i'm still very new and quite naive about it what can be done, and how to do things.

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

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

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.